Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
live logging is not working from a function called by @unittest.skipIf #3964
Based on an example at https://stackoverflow.com/questions/4673373/logging-within-py-test-tests let's create the following files in a directory:
Run from the directory with the FOO variable being set, e.g.:
As you can see logs from both setUp() and test_foo() appear, but not from _are_test_env_variables_set().
(you can also run with
This code is executed at import time (in the collection phase AFAIU). In the collection phase we don't have support for live-logging. Can you check if print() statements are written to the console if pytest is started with "-s"? If this is the case we should fix the live-logging of import-time logs.
@thisch Thx. I checked also with unchanged code but with -s. It seems to write
Then I added the print()-s as you requested:
Running with -s: all 3 print()-s are working (again you may need to scroll to the right to see
(Running without -s: no print() output appears.)