Test file names of the form foo_bar___init__.py error in 1.3.2, 1.3.3 and 1.3.4

Create issue
Issue #129 resolved
Trevor Bača created an issue


Starting in 1.3.2 test file names ending with the string 'init.py' cause py.test to fail.

This would seem to relate to #119 (fixed in 1.3.4). But this version of the problem persists in the 1.3.4 public release.

In the example below, the file foo_bar_init.py contains just a single print statement:

Desktop$ py.test foo_barinit.py ======================================= test session starts ======================================== platform darwin -- Python 2.6.1 -- pytest-1.3.4 test path 1: foo_barinit.py

foo_barinit.py E

============================================== ERRORS ============================================== ___ ERROR collecting /Users/trevorbaca/Desktop/foo_barinit.py ____ /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_plugin/pytest_runner.py:34: in pytest_make_collect_report

      result = collector._memocollect()

/Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/collect.py:230: in _memocollect return self._memoizedcall('_collected', self.collect) /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/collect.py:104: in _memoizedcall res = function() /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/pycollect.py:82: in collect dicts = [getattr(self.obj, 'dict', {})] /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/pycollect.py:17: in fget self._obj = obj = self._getobj() /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/pycollect.py:140: in _getobj return self._memoizedcall('_obj', self._importtestmodule) /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/collect.py:104: in _memoizedcall res = function() /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_test/pycollect.py:145: in _importtestmodule mod = self.fspath.pyimport(ensuresyspath=True) /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_path/local.py:539: in pyimport if not self.samefile(modfile): /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_path/local.py:73: in samefile return py.error.checked_call(os.path.samefile, str(self), str(other)) /Library/Python/2.6/site-packages/py-1.3.4-py2.6.egg/py/_error.py:80: in checked_call raise cls("%s%r" % (func.name, args)) E ENOENT: [No such file or directory]: samefile('/Users/trevorbaca/Desktop/foo_barinit.py', '/Users/trevorbaca/Desktop/foo_ba') ===================================== 1 error in 0.09 seconds ======================================

This matters for us at www.projectabjad.org because we author tests for the initializers of all of our classes in files named as FooBarClass_init.py.


Comments (4)

  1. Ronny Pfannschmidt

    seems like it doesn't relate to #119 but rather to a specific part in the pyimport code that checks the filename of a package/module in a slightly incorrect way in missing if there is a path separator before the `init.py` string

  2. Trevor Bača reporter

    Thanks so much Ronny and Holger. That was fast! I really appreciate you guys taking a look at the issue.


  3. Log in to comment