pytest: Internal Error when rerun occurs on tests that are members of a class using mark.

(Updated, added into about the marker registration)

We have some integration tests using selenium that pytest runs for us.

When a test fails and is rerun we see this:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/main.py", line 178, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/main.py", line 215, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/main.py", line 236, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pytest_rerunfailures.py", line 146, in pytest_runtest_protocol
INTERNALERROR>     reports = runtestprotocol(item, nextitem=nextitem, log=False)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/runner.py", line 73, in runtestprotocol
INTERNALERROR>     rep = call_and_report(item, "setup", log)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/runner.py", line 161, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/integrations/testrail/plugin.py", line 65, in pytest_runtest_makereport
INTERNALERROR>     if item.get_marker(TESTRAIL_PREFIX):
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/nodes.py", line 231, in get_marker
INTERNALERROR>     return MarkInfo(markers)
INTERNALERROR>   File "<attrs generated init ca81e36d524e8623cbf31cadd240224be62448db>", line 6, in __init__
INTERNALERROR>     self.combined = __attr_factory_combined(self)
INTERNALERROR>   File "/Users/seanperry/repos/work/integration-tests/env/lib/python2.7/site-packages/_pytest/mark/structures.py", line 288, in <lambda>
INTERNALERROR>     lambda self: reduce(Mark.combined_with, self._marks), takes_self=True
INTERNALERROR> TypeError: unbound method combined_with() must be called with Mark instance as first argument (got MarkDecorator instance instead)

The tests that are being rerun are methods of a test class declared like this:

from integrations.testrail.plugin import report_testrail

@pytest.mark.thing1
class TestSomethingWithinThing1(object)
    @pytest.fixture(autouse=True)
    def store_thing1_item(self, thing1_item):
        self.thing1_item = thing1_item

    @report_testrail('ABC123')
    def test_blah(self):
        # test something that fails and is rerun.....

There are no marks on the fixtures. The thing1 mark is registered in pytest.ini like so:

[pytest]
markers =
    thing1: Thing1 does this.....
    thing2: Thing2 does that....

Python version

$ env/bin/python --version
Python 2.7.15

pip list says:

env/bin/pip list
Package              Version
-------------------- ---------
atomicwrites         1.1.5
attrs                18.1.0
certifi              2018.4.16
chardet              3.0.4
click                6.7
configparser         3.5.0
EasyProcess          0.2.3
enum34               1.1.6
first                2.0.1
flake8               3.5.0
funcsigs             1.0.2
idna                 2.6
invoke               1.0.0
mccabe               0.6.1
mock                 2.0.0
more-itertools       4.2.0
pbr                  4.0.4
pip                  10.0.1
pip-tools            2.0.2
pluggy               0.6.0
py                   1.5.3
pycodestyle          2.3.1
pyflakes             1.6.0
pytest               3.6.1
pytest-rerunfailures 4.1
pytz                 2018.4
PyVirtualDisplay     0.2.1
requests             2.18.4
selenium             3.12.0
setuptools           39.2.0
six                  1.11.0
urllib3              1.22
wheel                0.31.1

I am running on OSX:

uname -a
Darwin My-MacBook-Pro.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I see, thanks. I still need to get back to #3501, hopefully will have time this week after a major Python 3 conversion at work. 😁