-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
plugin: loggingrelated to the logging builtin pluginrelated to the logging builtin pluginstatus: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivityreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
So I have this mind boggling issue for a test like this:
test_bug.py:
import logging
import pytest
def test_skip():
logging.info('blabla')
pytest.skip('muahaha')conftest.py:
from __future__ import print_function
import pytest
@pytest.mark.hookwrapper
def pytest_runtest_call(item):
if hasattr(item, 'funcargs'):
for _ in item.funcargs.items():
pass # i'd pull some data from fixtures here
result = yield
try:
result.get_result()
except Exception:
capman = item.config.pluginmanager.getplugin("capturemanager")
if capman:
capman.resume_global_capture()
print("""#####
##### DEBUG STUFF WHEN TEST FAILS
#####
""" % filename, file=sys.stderr)
if capman:
capman.suspend_capture_item(item, "setup")tox.ini:
[tox]
envlist = py27
skipsdist = true
[testenv]
commands =
pytest test_bug.py {posargs:}
deps =
pytest==3.3.2
pytest-splinter==1.8.5
pytest-xvfb==1.0.0
pytest-xdist==1.21.0
[pytest]
norecursedirs =
.git
.tox
.ve
python_files =
test_*.py
*_test.py
tests.py
addopts =
-rxEfsw
--strict
--doctest-modules
--doctest-glob=\*.rst
--tb=native
--max-slave-restart=5
xvfb_xauth = falseSometimes it pass and I get this:
platform linux2 -- Python 2.7.12, pytest-3.3.2, py-1.5.2, pluggy-0.6.0 -- /home/ionel/sandbox/.tox/py27/bin/python2.7
cachedir: .cache
rootdir: /home/ionel/sandbox, inifile: tox.ini
plugins: xvfb-1.0.0, xdist-1.21.0, splinter-1.8.5, forked-0.2
collected 1 item
test_bug.py::test_skip SKIPPED [100%]
========================================================================= short test summary info ==========================================================================
SKIP [1] /home/ionel/sandbox/test_bug.py:9: muahaha
======================================================================== 1 skipped in 0.02 seconds =========================================================================
Exception AttributeError: AttributeError('catch_log_handler',) in <generator object pytest_runtest_call at 0x7f7efb1130a0> ignored
_________________________________________________________________________________ summary __________________________________________________________________________________
py27: commands succeeded
congratulations :)
And sometimes it fails:
platform linux2 -- Python 2.7.12, pytest-3.3.2, py-1.5.2, pluggy-0.6.0 -- /home/ionel/sandbox/.tox/py27/bin/python2.7
cachedir: .cache
rootdir: /home/ionel/sandbox, inifile: tox.ini
plugins: xvfb-1.0.0, xdist-1.21.0, splinter-1.8.5, forked-0.2
collected 1 item
test_bug.py::test_skip SKIPPED [100%]
test_bug.py::test_skip ERROR [200%]
========================================================================= short test summary info ==========================================================================
ERROR test_bug.py::test_skip
SKIP [1] /home/ionel/sandbox/test_bug.py:9: muahaha
================================================================================== ERRORS ==================================================================================
______________________________________________________________________ ERROR at teardown of test_skip ______________________________________________________________________
Traceback (most recent call last):
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/ionel/sandbox/.tox/py27/local/lib/python2.7/site-packages/_pytest/logging.py", line 294, in _runtest_for
del item.catch_log_handler
AttributeError: catch_log_handler
==================================================================== 1 skipped, 1 error in 0.02 seconds ====================================================================
ERROR: InvocationError: '/home/ionel/sandbox/.tox/py27/bin/pytest test_bug.py -vv'
_________________________________________________________________________________ summary __________________________________________________________________________________
ERROR: py27: commands failed
Removing my weird helper from conftest makes the problem go away but I need it.
Also, if I remove some of those pytest plugins it doesn't error so often.
Any clue what's going on here?
Metadata
Metadata
Assignees
Labels
plugin: loggingrelated to the logging builtin pluginrelated to the logging builtin pluginstatus: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivityreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytype: bugproblem that needs to be addressedproblem that needs to be addressed