https://pantsbuild.org/ logo
#general
Title
# general
p

powerful-florist-1807

12/08/2022, 6:29 PM
Hi team, I used the Python
logging
library to log messages for tests. But I didn't see any output messages even though I applied the
-ldebug
option, e.x. "./pants -ldebug test ...". Does anyone know how to see the logging outputs? Thanks!
w

wide-midnight-78598

12/08/2022, 6:40 PM
Is this in your tests? Are you using
caplog
?
p

powerful-florist-1807

12/08/2022, 6:50 PM
Yes this is my test. I am logging, ex.
import logging
,
<http://logging.info|logging.info>(...)
h

happy-kitchen-89482

12/08/2022, 6:54 PM
Run with
--test-output=all
, otherwise we suppress the output of tests that pass
p

powerful-florist-1807

12/08/2022, 6:54 PM
OK
h

happy-kitchen-89482

12/08/2022, 7:05 PM
Does that work?
p

powerful-florist-1807

12/08/2022, 7:39 PM
No it doesn't. I still do not see the output.
It is not blocking anyways.
Also, the "--test-output=all" option already generates helpful information. I am debugging a slow unit test in our CI pipeline, and with this logging option, I am able to nail down the costly part to be building
requirements.pex
instead of the running the test itself.
h

happy-kitchen-89482

12/08/2022, 10:22 PM
Oh, wait, you also need to tell pytest to show output from passing tests.
You pass
-s
to pytest for that
so
./pants test --output=all <targets> -- -s
p

powerful-florist-1807

12/08/2022, 10:41 PM
It worked like a charm! Thanks Benjy!
5 Views