You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
atexit registered functions that print to stdout break test discovery #6581
I would expect the relevant tests to be discovered.
Actual behaviour
Test discovery fails because extra text is appended to whatever output is used to store the JSON description of the discovered tests, which subsequently causes a SyntaxError when parsing.
python /home/jjw/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear
Test Discovery failed:
SyntaxError: Unexpected token I in JSON at position 436
That is definitely a function of how our test discovery tooling works. We capture stdout while pytest discovery runs (and only show it on failure) and then write the discovery results to stdout. The best we could do for now is to clear all atexit handlers before the discovery tool finishes. However, doing so would require a bit of a hack (monkey-patching atexit.register()), so it might not be worth it.
FWIW, we are looking into an alternative approach that would not break with your atexit handler, but that would not be happening any time soon.
Activity
ericsnowcurrently commentedon Jul 15, 2019
That is definitely a function of how our test discovery tooling works. We capture stdout while pytest discovery runs (and only show it on failure) and then write the discovery results to stdout. The best we could do for now is to clear all atexit handlers before the discovery tool finishes. However, doing so would require a bit of a hack (monkey-patching
atexit.register()), so it might not be worth it.FWIW, we are looking into an alternative approach that would not break with your atexit handler, but that would not be happening any time soon.
joel-wright commentedon Jul 16, 2019
I love the sound of the alternative approach (I discovered this in a relatively large project where test discovery takes multiple minutes).
luabud commentedon Sep 17, 2019
Closing in favour of #6594.