py.test - How to print output when using pytest with xdist -
i'm using py.test run tests. i'm using pytest-xdist run tests in parallel. want see output of print statements in tests.
i have: ubuntu 15.10, python 2.7.10, pytest-2.9.1, pluggy-0.3.1.
here's test file:
def test_a(): print 'test_a' def test_b(): print 'test_b'
when run py.test, nothing printed. that's expected: default, py.test captures output.
when run py.test -s, prints test_a , test_b, should.
when run py.test -s -n2, again nothing printed. how can print statements work while using -n2?
i've read pytest + xdist without capturing output , bug report.
i see explain issue in github https://github.com/pytest-dev/pytest/issues/1693
pytest-xdist
use sys stdin/stdout control execution, way show print out should std.err.
import sys def test_a(): print >> sys.stderr, 'test_a' def test_b(): print >> sys.stderr, 'test_b'
not idea, work.
also should note arg -s
has no use if use xdist plugin.
in python 3, think logging.warning
better choice, since set write stderr default.
import logging logging.basicconfig(format='%(message)s') def test_a(): logging.warning('test_a') def test_b(): logging.warning('test_b')
Comments
Post a Comment