Skip to content

pytest-2.4.0.dev7 crashes with some autouse fixtures #336

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 Jul 24, 2013 · 6 comments
Closed

pytest-2.4.0.dev7 crashes with some autouse fixtures #336

pytestbot opened this issue Jul 24, 2013 · 6 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Andreas Pelme (BitBucket: pelme, GitHub: pelme)


I just installed the latest dev version of pytest (pip install -i http://pypi.testrun.org -U pytest) and got this error:


platform darwin -- Python 2.7.2 -- pytest-2.4.0.dev7 -- /Users/andreas/.virtualenvs/pk/bin/python
plugins: cache, contextfixture, cov, django, instafail, pep8, poo, xdist

________ ERROR collecting functional_tests/something.py _____________
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/runner.py:129: in __init__
>               self.result = func()
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/main.py:380: in _memocollect
>       return self._memoizedcall('_collected', lambda: list(self.collect()))
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/main.py:293: in _memoizedcall
>           res = function()
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/main.py:380: in <lambda>
>   return self._memoizedcall('_collected', lambda: list(self.collect()))
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/unittest.py:38: in collect
>           yield TestCaseFunction(name, parent=self)
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/python.py:953: in __init__
>                                                  funcargs=not isyield)
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/python.py:1476: in getfixtureinfo
>                                                             node)
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/python.py:1531: in getfixtureclosure
>       fixturenames_closure = self._getautousenames(parentid)
../../.virtualenvs/pk/lib/python2.7/site-packages/_pytest/python.py:1510: in _getautousenames
>           if nodeid.startswith(baseid):
E           TypeError: startswith first arg must be str, unicode, or tuple, not NoneType

I have not done any extensive debugging, but this is the value of basenames when the crash occurs:

['_django_clear_outbox', '_django_cursor_wrapper', '_django_db_marker', '_django_runner', '_django_set_urlconf', '_django_setup_unittest', '_live_server_helper']

These are the names of pytest-django autouse fixtures, so this might very well be a bug in pytest-django.

I can probably try to tackle this at august 1st, but my fixture internals knowledge is very limited. :-)

This crash does not occur with pytest 2.3.5.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


can you retry with trunk -- i bumped the version number and want to make sure you are really using the latest version.

@pytestbot
Copy link
Contributor Author

Original comment by Andreas Pelme (BitBucket: pelme, GitHub: pelme):


It is the same with the current trunk (2974:abfc7dc64ed4).

Anything else that might be useful to know about my setup?

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


I doubt you installed the latest version - it still shows pytest-2.4.dev7 but trunk has dev8 now. (UPDATE: ok, you probably didn't repaste the traceback). The line number of python.py:1510 doesn't show the line of your traceback. I'd like to have a trunk-based traceback if possible.

@pytestbot
Copy link
Contributor Author

Original comment by Andreas Pelme (BitBucket: pelme, GitHub: pelme):


I ran with dev8 too, but did not repost the traceback.

This is the full traceback:

$ py.test -x -vvvvv
===================================================== test session starts =====================================================
platform darwin -- Python 2.7.2 -- pytest-2.4.0.dev8 -- /Users/andreas/.virtualenvs/removed/bin/python
cachedir: /Users/andreas/code/removed/.cache
plugins: cache, contextfixture, cov, django, instafail, pep8, poo, xdist
_____________________________________ ERROR collecting functional_tests/removed.py _____________________________________
../pytest/_pytest/runner.py:129: in __init__
>               self.result = func()
../pytest/_pytest/main.py:380: in _memocollect
>       return self._memoizedcall('_collected', lambda: list(self.collect()))
../pytest/_pytest/main.py:293: in _memoizedcall
>           res = function()
../pytest/_pytest/main.py:380: in <lambda>
>   return self._memoizedcall('_collected', lambda: list(self.collect()))
../pytest/_pytest/unittest.py:38: in collect
>           yield TestCaseFunction(name, parent=self)
../pytest/_pytest/python.py:953: in __init__
>                                                  funcargs=not isyield)
../pytest/_pytest/python.py:1476: in getfixtureinfo
>                                                             node)
../pytest/_pytest/python.py:1531: in getfixtureclosure
>       fixturenames_closure = self._getautousenames(parentid)
../pytest/_pytest/python.py:1510: in _getautousenames
>           if nodeid.startswith(baseid):
E           TypeError: startswith first arg must be str, unicode, or tuple, not NoneType

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 1 error in 13.25 seconds ===================================================

I double checked the line numbers just to be sure, and this where the crash happends which matches my current checkout:

https://bitbucket.org/hpk42/pytest/src/abfc7dc64ed4f5a50e917ac8a30863be7e2361a7/_pytest/python.py?at=default#cl-1510

@pytestbot
Copy link
Contributor Author

Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Fix issue 336: autouse fixtures in plugins work again

When an autouse fixture in a plugin was encountered None was stored as nodeid
where it used to be ''. This broke the lookup of autouse fixtures later on.

This also adds another test for the normal fixture ordering which was slightly
wrong: a fixture without location was always added at the front of the fixture
list rather then at the end of the fixtures without location but before the
fixtures with location.

@pytestbot
Copy link
Contributor Author

Original comment by Andreas Pelme (BitBucket: pelme, GitHub: pelme):


I just ran my test suite with the current hg tip - everything works. Thanks a lot for fixing this!

Also, the new terminal reporting is very nice with the colors + summary/timing in non-verbose mode.

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant