kopia lustrzana https://github.com/corrscope/corrscope
Fix output pipeline tests (unique Popen mocks)
rodzic
a3e6db27b6
commit
a62f1561cf
|
@ -10,11 +10,15 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def Popen(mocker: 'pytest_mock.MockFixture'):
|
def Popen(mocker: 'pytest_mock.MockFixture'):
|
||||||
Popen = mocker.patch.object(subprocess, 'Popen', autospec=True)
|
real_Popen = subprocess.Popen
|
||||||
popen = Popen.return_value
|
|
||||||
|
|
||||||
|
def popen_factory(*args, **kwargs):
|
||||||
|
popen = mocker.create_autospec(real_Popen)
|
||||||
popen.stdin = open(os.devnull, "wb")
|
popen.stdin = open(os.devnull, "wb")
|
||||||
popen.stdout = open(os.devnull, "rb")
|
popen.stdout = open(os.devnull, "rb")
|
||||||
popen.wait.return_value = 0
|
popen.wait.return_value = 0
|
||||||
|
return popen
|
||||||
|
|
||||||
|
Popen = mocker.patch.object(subprocess, 'Popen', autospec=True)
|
||||||
|
Popen.side_effect = popen_factory
|
||||||
yield Popen
|
yield Popen
|
||||||
|
|
Ładowanie…
Reference in New Issue