Originally reported by: Lucas Cimon (BitBucket: LucasC, GitHub: LucasC)
To reproduce this issue, create a file named stupid_test.py with the following code :
def test_unicode():
print "*[PRINT TO STDOUT]*"
assert True
Then run the following:
$ py.test -v --capture=no --tx='1*popen' --dist=no stupid_test.py
# -> standard output contains "*[PRINT TO STDOUT]*"
$ py.test -v --capture=no --tx='1*popen' --dist=load stupid_test.py
# -> standard output is captured
$ py.test -v --capture=no --tx='1*popen' --dist=each stupid_test.py
# -> standard output is captured
I'm using the following version:
platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4 -- /usr/bin/python
_Original comment by_ Lucas Cimon (BitBucket: LucasC, GitHub: LucasC):
I had a quick look on how are nodes set up in pytest-xdist slavemanage.py.
It looks like stdout / stderr could be aggregated & redirected using the method described in this pytest-dev thread and attachment by @hpk42.
Would that be a reasonable solution ?
_Original comment by_ Ragnar Rova (BitBucket: ragnar_rova, GitHub: ragnar_rova):
I have a similar issue, running tests that run fabric like so:
py.test -s -n4 --boxed
...
#!python
fabric_env/lib/python2.7/site-packages/fabric/io.py:211: in input_loop
r, w, x = select([sys.stdin], [], [], 0.0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.capture.DontReadFromInput instance at 0x1053563b0>
def fileno(self):
> raise ValueError("redirected Stdin is pseudofile, has no fileno()")
E ValueError: redirected Stdin is pseudofile, has no fileno()
fabric_env/lib/python2.7/site-packages/_pytest/capture.py:441: ValueError
_Original comment by_ Ragnar Rova (BitBucket: ragnar_rova, GitHub: ragnar_rova):
This got me halfway, but introduced other errors: http://stackoverflow.com/questions/27006884/pytest-xdist-without-capturing-output
I would like to do the same, disabling capture while using --dist-load.
I was able to do this by logging everything in my tests to STDERR. It was working fine until pytest release 2.6.0. In that release commit ce8678e modified something, which I don't understand yet. After that I cannot disable capturing at all with --dist=load.
Can anyone please help me to understand why it is not possible to disable capturing when distributing tests? Maybe there's a good reason I'm not aware of.
Can anyone please help me to understand why it is not possible to disable capturing when distributing tests? Maybe there's a good reason I'm not aware of.
I don't think is there any specific reason for that: I think it works like this because that's how the pytest runner works by default, and each slave uses the default option for capturing. I think all it is required is for the master node to pass that configuration along to the slaves.
Thank you nicoddemus! I'm going to dig deeper in xdist and pytest to figure out the solution ;)
This got me halfway, but introduced other errors: http://stackoverflow.com/questions/27006884/pytest-xdist-without-capturing-output
This suggestion is working for me however
If I do this:
capman._method = str(config.getoption("--capture"))
Instead of this:
capman._method = "no"
Then I can turn on and off capturing STDERR during distributed tests.
Fixed in #1124
I'm using -n3 -d and each of my tests have print statements that are ignored by pytest. Im using pytest 2.9.1 and pytest-xdist-1.14.
py.test -sv -rx --color=yes -n3 -d --junit-xml=output.xml
py.test -sv -rx --color=yes -n3 -d --junit-xml=output.xml --capture=no
How do I see stdout? Doesn't appear in my junit xml file either when I'm parallelizing the tests.
I'm using 2.9.1 on Windows with Python 3.5 and, similarly to @nitrocode, I also can not see my print outputs while using -n N. Running without xdist prints output to console as expected.
currently cdist and nocapture is not compatible, the next major version of xdist will be
Most helpful comment
currently cdist and nocapture is not compatible, the next major version of xdist will be