helpful-rocket-63313
11/16/2023, 2:37 PMtest
goal doesn't output, print
statements but only outputs logging
outputs
# temp_test.py
from loguru import logger
def test_simple():
print("Hello")
print(f"Hello 2")
logger.info("This is a test message")
assert True
when I run
pants --test-output=all --pytest-args="-s -vv" test temp_test.py
I correctly see the output of logger
in console, but not of print
statements
======================= 1 passed, 2 warnings in 0.67s =========================
2023-11-16 09:36:30.990 | INFO | temp_test:test_simple:7 - This is a test message
If i explicitly run with pytest
i can see the print statement output. Am i missing any configuration or could this be a bug ?gorgeous-winter-99296
11/16/2023, 3:57 PM-s
when -rP
would work better? -s
disables capture completely, so it'll appear in the "test progress" output which makes it hard to see sometimes. -rP
puts it at the end which is generally easier to spot.helpful-rocket-63313
11/16/2023, 4:09 PM-rP
as well. The issue i am seeing is output of print
isn't rendered on console, but of logger
is rendered.
Tom, what did you use to print Here I am
. Did you use print
statement or some logger
? What version of pants are you using? I am using 2.18.0
gorgeous-winter-99296
11/16/2023, 4:12 PMhelpful-rocket-63313
11/16/2023, 4:12 PMgorgeous-winter-99296
11/16/2023, 4:15 PMlittle-pilot-11155
11/16/2023, 11:31 PM==================================== PASSES ====================================
_________________________________ test_simple __________________________________
----------------------------- Captured stdout call -----------------------------
Hello
Hello 2
----------------------------- Captured stderr call -----------------------------
2023-11-16 23:16:38.852 | INFO | test:test_simple:11 - This is a test message
Bear in mind that loguru
by default outputs to stderr
(see this section).
The logger is pre-configured for convenience with a default handler which writes messages toSo something is intercepting your.sys.stderr
stdout
. Maybe try this trick?