Skip to content
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

from mock import call breaks test collector #1044

Closed
lithammer opened this issue Sep 21, 2015 · 5 comments
Closed

from mock import call breaks test collector #1044

lithammer opened this issue Sep 21, 2015 · 5 comments
Milestone

Comments

@lithammer
Copy link

To reproduce:

$ echo 'from mock import call' > test_foo.py
$ virtualenv env
$ ./env/bin/pip install pytest==2.8.0 mock==1.3.0
$ ./env/bin/py.test test_foo.py
========================== test session starts ==========================
platform darwin -- Python 2.6.6, pytest-2.8.0, py-1.4.30, pluggy-0.3.1
rootdir: /Users/Peter/src/github.com/edgeware, inifile:
collected 0 items / 1 errors

================================ ERRORS =================================
_____________________ ERROR collecting test_foo.py ______________________
env/lib/python2.6/site-packages/_pytest/runner.py:149: in __init__
    self.result = func()
env/lib/python2.6/site-packages/_pytest/main.py:437: in _memocollect
    return self._memoizedcall('_collected', lambda: list(self.collect()))
env/lib/python2.6/site-packages/_pytest/main.py:317: in _memoizedcall
    res = function()
env/lib/python2.6/site-packages/_pytest/main.py:437: in <lambda>
    return self._memoizedcall('_collected', lambda: list(self.collect()))
env/lib/python2.6/site-packages/_pytest/python.py:575: in collect
    return super(Module, self).collect()
env/lib/python2.6/site-packages/_pytest/python.py:435: in collect
    l.sort(key=lambda item: item.reportinfo()[:2])
env/lib/python2.6/site-packages/_pytest/python.py:435: in <lambda>
    l.sort(key=lambda item: item.reportinfo()[:2])
env/lib/python2.6/site-packages/_pytest/python.py:371: in reportinfo
    assert isinstance(lineno, int)
E   assert isinstance(compat_co_firstlineno, int)
======================== 1 error in 0.22 seconds ========================
@lithammer
Copy link
Author

Also, just importing mock and running mock.call(...) works. And importing as an alias doesn't work either from mock import call as _call.

@lithammer lithammer changed the title from mock import call produces assertion error by testrunner from mock import call breaks test collector Sep 21, 2015
@The-Compiler
Copy link
Member

Probably a duplicate of #1035

@RonnyPfannschmidt RonnyPfannschmidt added this to the 2.8.1 milestone Sep 22, 2015
@RonnyPfannschmidt
Copy link
Member

closing as duplicate

@sahilthapar
Copy link

sahilthapar commented Oct 18, 2017

I'm having the same issue with
Python 3.6.2
pytest 3.2.2
mock 2.0.0

@nicoddemus
Copy link
Member

@sahilthapar hmm this was expected to be fixed. Could you open a new issue with a minimal reproducible example that demonstrates the problem? Thanks!

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

5 participants