Fix output pipeline tests (unique Popen mocks)

pull/357/head
nyanpasu64 2018-08-29 00:57:08 -07:00
rodzic a3e6db27b6
commit a62f1561cf
1 zmienionych plików z 10 dodań i 6 usunięć

Wyświetl plik

@ -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