Skip to content

pytest-cov 2.1.0 doesn't work with pytest 2.8.0 #91

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
kmike opened this issue Sep 19, 2015 · 11 comments
Closed

pytest-cov 2.1.0 doesn't work with pytest 2.8.0 #91

kmike opened this issue Sep 19, 2015 · 11 comments

Comments

@kmike
Copy link

kmike commented Sep 19, 2015

Hey,

It looks like pytest-cov 2.1.0 is not compatible with pytest 2.8.0 (released a couple days ago): every other test fails. It works fine with pytest 2.7.0 or with pytest-cov plugin disabled.

py27 runtests: commands[0] | py.test --cov=scrapy --cov-report= tests/test_utils_python.py
============================================================= test session starts =============================================================
platform darwin -- Python 2.7.6, pytest-2.8.0, py-1.4.30, pluggy-0.3.1
rootdir: /Users/kmike/svn/scrapy, inifile: pytest.ini
plugins: cov-2.1.0
collected 21 items 

tests/test_utils_python.py .E.E.E.E.EE.E.E.E.EE.E.E.E.EE.E.E.E.E.ETraceback (most recent call last):
  File ".tox/py27/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/config.py", line 48, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 115, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 110, in wrap_session
    exitstatus=session.exitstatus)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 247, in _wrapped_call
    call_outcome = _CallOutcome(func)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/terminal.py", line 360, in pytest_sessionfinish
    outcome = yield
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    _reraise(*ex)  # noqa
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 55, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 375, in teardown_all
    self._pop_and_teardown()
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 348, in _pop_and_teardown
    self._teardown_with_finalization(colitem)
  File "/Users/kmike/svn/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 371, in _teardown_with_finalization
    or isinstance(colitem, tuple)
AssertionError
ERROR: InvocationError: '/Users/kmike/svn/scrapy/.tox/py27/bin/py.test --cov=scrapy --cov-report= tests/test_utils_python.py'
ionelmc added a commit that referenced this issue Sep 20, 2015
@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

I've updatd the test deps. Lets see if we got any failures.

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

@kmike does this issue happen with pytest-cov 2.0?

Also, could you post some details about the AssertionError (like what value colitem has - add some prints in the code or use hunter)?

@nicoddemus
Copy link
Member

Cool, didn't know about hunter... it will certainly be useful. 😄

@kmike
Copy link
Author

kmike commented Sep 20, 2015

@ionelmc colitem is <DoctestModule 'tests/test_utils_python.py'>. I'm running Scrapy testing suite; to reproduce it you can e.g. clone https://github.com/scrapy/scrapy repo and run tox -e py27 -- tests/test_utils_python.py from the source root.

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

@kmike quite strange, but this makes your suite pass:

diff --git a/pytest.ini b/pytest.ini
index 73d1696..69460aa 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,5 +1,4 @@
 [pytest]
-usefixtures = chdir
 python_files=test_*.py __init__.py
 python_classes=
 addopts = --doctest-modules --assert=plain

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

With this change it will still fail

diff --git a/tox.ini b/tox.ini
index 8b4c9e8..f071189 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,7 +15,7 @@ deps =
     leveldb
     -rtests/requirements.txt
 commands =
-    py.test --cov=scrapy --cov-report= {posargs:scrapy tests}
+    py.test {posargs:scrapy tests}

 [testenv:precise]
 basepython = python2.7

I'm sorry but I don't think this a pytest-cov issue at all 😁

@kmike
Copy link
Author

kmike commented Sep 20, 2015

@ionelmc thanks for checking it!
For me it passes if you remove pytest-cov from tests/requirements.txt and recreate tox environment.

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

This is what I get:

$ tox -r -e py27 -- tests/test_utils_python.py -vv

GLOB sdist-make: /home/ionel/osp/scrapy/setup.py
py27 recreate: /home/ionel/osp/scrapy/.tox/py27
py27 installdeps: -rrequirements.txt, boto, Pillow, leveldb, -rtests/requirements.txt
py27 inst: /home/ionel/osp/scrapy/.tox/dist/Scrapy-1.1.0.dev1.zip
py27 installed: -f file:///home/ionel/.pip/wheels,blessings==1.6,boto==2.38.0,bpython==0.14.2,cffi==1.2.1,characteristic==14.3.0,cryptography==1.0.1,cssselect==0.9.1,curtsies==0.1.19,decorator==4.0.2,enum34==1.0.4,Flask==0.10.1,funcsigs==0.4,greenlet==0.4.9,idna==2.0,ipaddress==1.0.14,ipython==4.0.0,ipython-genutils==0.1.0,itsdangerous==0.24,Jinja2==2.8,jmespath==0.7.1,leveldb==0.193,lxml==3.4.4,MarkupSafe==0.23,mitmproxy==0.10.1,mock==1.3.0,ndg-httpsclient==0.4.0,netlib==0.10.1,parsel==1.0.1,path.py==8.1.1,pbr==1.8.0,pexpect==3.3,pickleshare==0.5,Pillow==2.9.0,py==1.4.30,pyasn1==0.1.8,pyasn1-modules==0.0.7,pycparser==2.14,PyDispatcher==2.0.5,Pygments==2.0.2,pyOpenSSL==0.15.1,pytest==2.8.0,pytest-twisted==1.5,queuelib==1.4.2,requests==2.7.0,Scrapy==1.1.0.dev1,service-identity==14.0.0,simplegeneric==0.8.1,six==1.9.0,testfixtures==4.3.3,traitlets==4.0.0,Twisted==15.4.0,urwid==1.3.0,w3lib==1.12.0,Werkzeug==0.10.4,wheel==0.26.0,zope.interface==4.1.2
py27 runtests: PYTHONHASHSEED='860399476'
py27 runtests: commands[0] | py.test tests/test_utils_python.py -vv
============================================================================================================ test session starts ============================================================================================================
platform linux2 -- Python 2.7.6, pytest-2.8.0, py-1.4.30, pluggy-0.3.1 -- /home/ionel/osp/scrapy/.tox/py27/bin/python
cachedir: .cache
rootdir: /home/ionel/osp/scrapy, inifile: pytest.ini
plugins: twisted-1.5
collected 21 items

tests/test_utils_python.py::ToUnicodeTest::test_converting_a_latin_1_encoded_string_to_unicode PASSED
tests/test_utils_python.py::ToUnicodeTest::test_converting_a_latin_1_encoded_string_to_unicode ERROR
tests/test_utils_python.py::ToUnicodeTest::test_converting_a_strange_object_should_raise_TypeError PASSED
tests/test_utils_python.py::ToUnicodeTest::test_converting_a_strange_object_should_raise_TypeError ERROR
tests/test_utils_python.py::ToUnicodeTest::test_converting_a_unicode_to_unicode_should_return_the_same_object PASSED
tests/test_utils_python.py::ToUnicodeTest::test_converting_a_unicode_to_unicode_should_return_the_same_object ERROR
tests/test_utils_python.py::ToUnicodeTest::test_converting_an_utf8_encoded_string_to_unicode PASSED
tests/test_utils_python.py::ToUnicodeTest::test_converting_an_utf8_encoded_string_to_unicode ERROR
tests/test_utils_python.py::ToUnicodeTest::test_errors_argument PASSED
tests/test_utils_python.py::ToUnicodeTest::test_errors_argument ERROR
tests/test_utils_python.py::ToBytesTest::test_converting_a_regular_bytes_to_bytes_should_return_the_same_object ERROR
tests/test_utils_python.py::ToBytesTest::test_converting_a_strange_object_should_raise_TypeError PASSED
tests/test_utils_python.py::ToBytesTest::test_converting_a_strange_object_should_raise_TypeError ERROR
tests/test_utils_python.py::ToBytesTest::test_converting_a_unicode_object_to_a_latin_1_encoded_string PASSED
tests/test_utils_python.py::ToBytesTest::test_converting_a_unicode_object_to_a_latin_1_encoded_string ERROR
tests/test_utils_python.py::ToBytesTest::test_converting_a_unicode_object_to_an_utf_8_encoded_string PASSED
tests/test_utils_python.py::ToBytesTest::test_converting_a_unicode_object_to_an_utf_8_encoded_string ERROR
tests/test_utils_python.py::ToBytesTest::test_errors_argument PASSED
tests/test_utils_python.py::ToBytesTest::test_errors_argument ERROR
tests/test_utils_python.py::MemoizedMethodTest::test_memoizemethod_noargs ERROR
tests/test_utils_python.py::IsBinaryTextTest::test_isbinarytext PASSED
tests/test_utils_python.py::IsBinaryTextTest::test_isbinarytext ERROR
tests/test_utils_python.py::IsBinaryTextTest::test_one_with_encoding PASSED
tests/test_utils_python.py::IsBinaryTextTest::test_one_with_encoding ERROR
tests/test_utils_python.py::IsBinaryTextTest::test_real_binary_bytes PASSED
tests/test_utils_python.py::IsBinaryTextTest::test_real_binary_bytes ERROR
tests/test_utils_python.py::IsBinaryTextTest::test_utf_16_strings_contain_null_bytes PASSED
tests/test_utils_python.py::IsBinaryTextTest::test_utf_16_strings_contain_null_bytes ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_equal_attributes ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_get_func_args PASSED
tests/test_utils_python.py::UtilsPythonTestCase::test_get_func_args ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict PASSED
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict_keys_only PASSED
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict_keys_only ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict_tuples PASSED
tests/test_utils_python.py::UtilsPythonTestCase::test_stringify_dict_tuples ERROR
tests/test_utils_python.py::UtilsPythonTestCase::test_weakkeycache PASSED
tests/test_utils_python.py::UtilsPythonTestCase::test_weakkeycache ERRORTraceback (most recent call last):
  File ".tox/py27/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/config.py", line 48, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 115, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 110, in wrap_session
    exitstatus=session.exitstatus)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/terminal.py", line 361, in pytest_sessionfinish
    outcome.get_result()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    _reraise(*ex)  # noqa
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 55, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 375, in teardown_all
    self._pop_and_teardown()
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 348, in _pop_and_teardown
    self._teardown_with_finalization(colitem)
  File "/home/ionel/osp/scrapy/.tox/py27/lib/python2.7/site-packages/_pytest/runner.py", line 371, in _teardown_with_finalization
    or isinstance(colitem, tuple)
AssertionError
ERROR: InvocationError: '/home/ionel/osp/scrapy/.tox/py27/bin/py.test tests/test_utils_python.py -vv'
__________________________________________________________________________________________________________________ summary __________________________________________________________________________________________________________________
ERROR:   py27: commands failed

pytest-cov is not installed and it still fails

@ionelmc
Copy link
Member

ionelmc commented Sep 20, 2015

Maybe @nicoddemus or @RonnyPfannschmidt or @flub have different input here. To me this looks like a unittest integration bug (same finalizers being called more than once). I avoid the TestCases like the plague so it's not something that I understand very well.

A more detailed trace:

             _pytest/runner.py:54    call      def pytest_sessionfinish(session):
             _pytest/runner.py:55    line          session._setupstate.teardown_all()
             _pytest/runner.py:373   call          def teardown_all(self):
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>, <UnitTestCase 'ToUnicodeTest'>]
             _pytest/runner.py:374   line              while self.stack:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>, <UnitTestCase 'ToUnicodeTest'>]
             _pytest/runner.py:375   line                  self._pop_and_teardown()
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>, <UnitTestCase 'ToUnicodeTest'>]
             _pytest/runner.py:346   call          def _pop_and_teardown(self):
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>, <UnitTestCase 'ToUnicodeTest'>]
             _pytest/runner.py:347   line              colitem = self.stack.pop()
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>, <UnitTestCase 'ToUnicodeTest'>]
             _pytest/runner.py:348   line              self._teardown_with_finalization(colitem)
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:365   call          def _teardown_with_finalization(self, colitem):
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:366   line              self._callfinalizers(colitem)
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:350   call          def _callfinalizers(self, colitem):
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:351   line              finalizers = self._finalizers.pop(colitem, None)
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <UnitTestCase 'ToUnicodeTest'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
               _pytest/main.py:300   call          def __hash__(self):
               _pytest/main.py:301   line              return hash(self.nodeid)
               _pytest/main.py:288   call          @property
                                        |          def nodeid(self):
               _pytest/main.py:291   line              try:
               _pytest/main.py:292   line                  return self._nodeid
               _pytest/main.py:292   return                return self._nodeid
                                     ...       return value: 'tests/test_utils_python.py::ToUnicodeTest'
               _pytest/main.py:301   return            return hash(self.nodeid)
                                     ...       return value: -6170353195940023055
             _pytest/runner.py:352   line              exc = None
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:353   line              while finalizers:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:354   line                  fin = finalizers.pop()
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:355   line                  try:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:356   line                      fin()
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:353   line              while finalizers:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:362   line              if exc:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:362   return            if exc:
                                     ...       return value: None
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:367   line              if hasattr(colitem, "teardown"):
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:368   line                  colitem.teardown()
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
               _pytest/main.py:306   call          def teardown(self):
               _pytest/main.py:307   line              pass
               _pytest/main.py:307   return            pass
                                     ...       return value: None
             _pytest/runner.py:369   line              for colitem in self._finalizers:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <UnitTestCase 'ToUnicodeTest'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:370   line                  assert colitem is None or colitem in self.stack \
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <Session 'scrapy'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:369   line              for colitem in self._finalizers:
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <Session 'scrapy'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:370   line                  assert colitem is None or colitem in self.stack \
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <DoctestModule 'tests/test_utils_python.py'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:371   line                   or isinstance(colitem, tuple)
                                     vars      self._finalizers.keys() => [<Session 'scrapy'>, <DoctestModule 'tests/test_utils_python.py'>]
                                     ...       colitem => <DoctestModule 'tests/test_utils_python.py'>
                                     ...       self.stack => [<Session 'scrapy'>, <Module 'tests/test_utils_python.py'>]
             _pytest/runner.py:371   exception              or isinstance(colitem, tuple)
                                     ...       exception value: (<type 'exceptions.AssertionError'>, AssertionError(), <traceback object at 0x7f1745c96098>)

It seems self._finalizers don't match what's in self.stack.

@kmike
Copy link
Author

kmike commented Sep 21, 2015

@ionelmc ouch, sorry. I was trying to figure out what's the best place to fire this bug (pytest, pytest-cov or pytest-twisted), and disabled pytest-cov and pytest-twisted plugins, but it was a late night :) You're right, it fails without pytest-cov. Thanks for the help!

@ionelmc
Copy link
Member

ionelmc commented Sep 30, 2015

Related bug in pytest: pytest-dev/pytest#1057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants