Skip to content

Collection fails in python 2.6 if mock.call is imported #1103

Closed
@dairiki

Description

@dairiki

As of yet, I have no idea why this happens, but, using

  • python 2.6
  • mock 1.3.0
  • py.test 2.8.1 (or 2.8.0)

With test_mock.py containing the single line:

from mock import call

py.test test_mock.py fails with

============================= test session starts ==============================
platform linux2 -- Python 2.6.8, pytest-2.8.0, py-1.4.30, pluggy-0.3.1
rootdir: /srv/w/users/dairiki/git/discnw/btp_buildout, inifile: pytest.ini
collected 0 items / 1 errors 

==================================== ERRORS ====================================
______________________ ERROR collecting junk/test_mock.py ______________________
py26/lib/python2.6/site-packages/_pytest/runner.py:149: in __init__
    self.result = func()
py26/lib/python2.6/site-packages/_pytest/main.py:437: in _memocollect
    return self._memoizedcall('_collected', lambda: list(self.collect()))
py26/lib/python2.6/site-packages/_pytest/main.py:317: in _memoizedcall
    res = function()
py26/lib/python2.6/site-packages/_pytest/main.py:437: in <lambda>
    return self._memoizedcall('_collected', lambda: list(self.collect()))
py26/lib/python2.6/site-packages/_pytest/python.py:575: in collect
    return super(Module, self).collect()
py26/lib/python2.6/site-packages/_pytest/python.py:435: in collect
    l.sort(key=lambda item: item.reportinfo()[:2])
py26/lib/python2.6/site-packages/_pytest/python.py:435: in <lambda>
    l.sort(key=lambda item: item.reportinfo()[:2])
py26/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.26 seconds ============================

This same error seems to happen when collecting tests from any source which includes a from mock import call.

(This does not happen with pytest < 2.8. Also this does not seem to be a problem with python 2.7.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions