Closed newskooler closed 4 years ago
pytest has nothing to do with coverage. If you run Python code in another process and want it to be covered, you will need to set coverage.py up correctly or use the pytest-cov plugin.
Closing this now as I don't think there's anything actionable for pytest here, but feel free to follow up if needed!
Well this gives me a good lead. Thanks.
I have an async python function which connects to a websocket and then uses a while True loop to collect and save the information form the websocket to a DB.
The function looks very similar to this one (source);:
I was thinking of way to test it and tried getting some help from Stack Overflow (you can see my question here). The way I figured out to test whether the function connects and writes correctly the information is by running the. while loop for a limited time and then checking the results and cleaning afterwards.
I achieve the time out by running the function via a
multiprocessor
. Afterwards, following a bunch of asserts, I evaluate if the results are correct.All of the above works fine, however when I look at the coverage report, it wrongly states the much of the lines of code are not covered.
Is this a bug or is it because I time out the while True loop through a multiprocessor?
How can I fix this?