Skip to content

IOError when writing --junitxml report when run via xdist, sometimes #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Mar 9, 2013 · 1 comment
Closed
Labels
plugin: xdist related to the xdist external plugin type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: reuben fletcher-costin (BitBucket: rfc, GitHub: rfc)


Hi,

py.test crashed 3 out of 10 times when using py.test -n8 --junitxml report.xml to run the following trivial test:

#!python

def test_foo():
    assert True

When it crashes, the output looks like this (although sometimes more than 1 node may crash per run):

#!text

C:\test_pytest>py.test -n8 --junitxml report.xml
===================================================================== test session starts ====================
platform win32 -- Python 2.7.3 -- pytest-2.3.4
plugins: cov, xdist
gw0 [0] / gw1 [0] / gw2 [0] / gw3 [0] / gw4 [0] / gw5 [0] / gw6 [0] / gw7 [0]
scheduling tests via LoadScheduling
[gw5] node down: Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\execnet\gateway_base.py", line 800, in executetask
    do_exec(co, loc)
  File "<string>", line 1, in do_exec
  File "", line 139, in <module>
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 422, in __call__
    return self._docall(methods, kwargs)
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 433, in _docall
    res = mc.execute()
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 351, in execute
    res = method(**kwargs)
  File "C:\Python27\lib\site-packages\_pytest\main.py", line 107, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "C:\Python27\lib\site-packages\_pytest\main.py", line 99, in wrap_session
    exitstatus=session.exitstatus or (session._testsfailed and 1))
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 422, in __call__
    return self._docall(methods, kwargs)
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 433, in _docall
    res = mc.execute()
  File "C:\Python27\lib\site-packages\_pytest\core.py", line 351, in execute
    res = method(**kwargs)
  File "C:\Python27\lib\site-packages\_pytest\junitxml.py", line 202, in pytest_sessionfinish
    logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
  File "C:\Python27\lib\codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 22] invalid mode ('wb') or filename: 'C:\\test_pytest\\report.xml'


-------------------------------------------------------- generated xml file: C:\test_pytest\report.xml -------
======================================================================  in 1.47 seconds ======================

These results are from windows 7 professional with python 2.7.3, running on a machine with four cores:

#!text

py.test --version
This is py.test version 2.3.4, imported from C:\Python27\lib\site-packages\pytest.pyc
setuptools registered plugins:
  pytest-cov-1.6 at C:\Python27\lib\site-packages\pytest_cov.pyc
  pytest-xdist-1.8 at C:\Python27\lib\site-packages\xdist\plugin.pyc

python --version
Python 2.7.3

>>> import execnet
>>> execnet.__version__
'1.1'

My guess: perhaps each node is writing its own copy of the xml report to the same filename.


@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


fix issue 271 - dont write junitxml on slave nodes

@pytestbot pytestbot added type: bug problem that needs to be addressed plugin: xdist related to the xdist external plugin labels Jun 15, 2015
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: xdist related to the xdist external plugin type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant