Fix issue with basilisp test standard streams output
#1082
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
can you please review patch to address the
basilisp testfailure on MS-Windows. It fixes #1080.The problem arises because pytest's mechanism for capturing standard streams during tests breaks when those streams are saved before pytest.main is called and then used in the test. This happens when running
basilisp testfrom the CLI:In
basilisp.init,sys.stdoutandsys.stderrare saved to the*out*and*err*dynamic variables beforepytest.mainis called. If a test prints anything, it tries to write to these original streams, causing failures due to an issue I just reported in pytest-dev/pytest#12876.This patch rebinds
*out*and*err*to the streams set bypytestand restores them whenpytestfinishes (via theconfigurefunctions). I've tested it with a case that prints to*out*and*err*at the top level, inside a test, and inside a fixture, and it works as expected.I’d also like to discuss
Basilispintegration tests, which I think the above testing falls under, though there’s currently no support for such tests inBasilisp.Ideally I think, I would like to create a
Basilispproject in a temporary directory, add the above test, install the fix alongsidepytest, activate the environment, and then runbasilisp test.Do you have any suggestions how to extend the
Basilisptest suite to implement this? or shall I open a new ticket for this discussion? I was thinking of having a new--integrationpytest option for these tests, something I have been experimenting with in the basilisp-blender package.Thanks