-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Robustify tests of iterable_subprocess
#614
Robustify tests of iterable_subprocess
#614
Conversation
This commit modifies the test `test_success_returncode_available_from_generator_with_exception` to accept `0` and `-15` return codes. The reason is that any `StopIteration`-exception that occurs before the subprocess has exited will lead to a subprocess termination and to a `-15` return code. There seem to be system configurations in which this situation appears. The new test is renamed to `test_returncode_available_from_generator_with_exception`.
03ec8c5
to
b83c101
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #614 +/- ##
=======================================
Coverage 92.99% 92.99%
=======================================
Files 160 160
Lines 11863 11863
Branches 1795 1795
=======================================
Hits 11032 11032
- Misses 640 642 +2
+ Partials 191 189 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That rationale is sound. I wonder, though, shouldn't the implementation follow that rationale more closely? Now we are expecting one of two possible return values, rather than any.
Is there a reason not to test for is not None
?
I used this comparison before. But I think this case is already covered by the test I think there are only two possible values to assert. On a Linux system, all exceptions that are raised before the subprocess exited will lead to a In conclusion, I would only expect return codes
WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Let's run with it then. I added a suggestion to include the explanation into the test code.
Co-authored-by: Michael Hanke <michael.hanke@gmail.com>
This PR modifies the test
datalad_next.iterable_subprocess.test_iterable_subprocess.test_success_returncode_available_from_generator_with_exception
to simply check for a non-None
return code instead of checking for a0
return code.The reason is that a
StopIteration
-exception that occurs before the subprocess has terminated might lead to a non-0
return code, thus failing the test. Some environments might trigger such an early exception, e.g. due to some unexpected stdout-configuration. In other words, we cannot guarantee a0
return code in all environments. But we can guarantee, that a return code is available when theiterable_subprocess
-context is exited with an exception.The test is renamed to
test_returncode_available_from_generator_with_exception
.This should make the test robust enough to prevent this test failure.