`test_returncode_available_from_generator_with_exception` unreliable on windows
Closed this issue · 2 comments
mih commented
The log is below -- happening a lot.
The test specifically talks about linux systems. Maybe it should get a platform-conditional execution.
@christian-monch what is your view on this?
================================== FAILURES ===================================
___________ test_returncode_available_from_generator_with_exception ___________
def test_returncode_available_from_generator_with_exception():
with pytest.raises(StopIteration):
with iterable_subprocess(['echo', 'a'], ()) as echo:
while True:
next(echo)
# On a Linux system, all exceptions that are raised before the subprocess
# exited will lead to a -15 return code. If StopIteration is raised, the
# subprocess will either have terminated which results in a 0-return code,
# or the subprocess is still running and will therefore be terminated which
# results in a -15 return code. Any other exception than StopIteration,
# e.g. a CommandError because echo could not be found, would lead to an
# early test-exit and not proceed to the assign-statement.
> assert echo.returncode in (0, -15)
E assert 1 in (0, -15)
E + where 1 = <datasalad.iterable_subprocess.iterable_subprocess.OutputFrom object at 0x0000014BF4D9FD60>.returncode
datasalad\iterable_subprocess\test_iterable_subprocess.py:424: AssertionError
=========================== short test summary info ===========================
FAILED datasalad/iterable_subprocess/test_iterable_subprocess.py::test_returncode_available_from_generator_with_exception - assert 1 in (0, -15)
+ where 1 = <datasalad.iterable_subprocess.iterable_subprocess.OutputFrom object at 0x0000014BF4D9FD60>.returncode
======================== 1 failed, 62 passed in 18.67s ========================
christian-monch commented
I am looking into it. I think platform specific execution might indeed be necessary
christian-monch commented
Looking at the code again, the solution is simple. On Windows Popen.terminate()
will always lead to return code of 1
on Windows. This return code can just be added to the valid return codes.
PR #34 contains the solution.