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
|
||||
def Popen(mocker: 'pytest_mock.MockFixture'):
|
||||
real_Popen = subprocess.Popen
|
||||
|
||||
def popen_factory(*args, **kwargs):
|
||||
popen = mocker.create_autospec(real_Popen)
|
||||
popen.stdin = open(os.devnull, "wb")
|
||||
popen.stdout = open(os.devnull, "rb")
|
||||
popen.wait.return_value = 0
|
||||
return popen
|
||||
|
||||
Popen = mocker.patch.object(subprocess, 'Popen', autospec=True)
|
||||
popen = Popen.return_value
|
||||
|
||||
popen.stdin = open(os.devnull, "wb")
|
||||
popen.stdout = open(os.devnull, "rb")
|
||||
popen.wait.return_value = 0
|
||||
|
||||
Popen.side_effect = popen_factory
|
||||
yield Popen
|
||||
|
|
Ładowanie…
Reference in New Issue