py.test seems gather tests from upper directories

Create issue
Issue #121 duplicate
Bluebird created an issue

I don't know what's wrong with my setup, but since I upgraded py.test , it no longer restrict itself to the current directory and subdirectories, it looks up for other directories.

{{{

!bash

hilippe@pc-philippe /cygdrive/d/work/elc-dev $ ls -d elc*
elc-memory/ elc-py26/ elc-work-fh1/ elc2/
elc-merge-linkchecker/ elc-ref/ elc1/ elc3/

Philippe@pc-philippe /cygdrive/d/work/elc-dev $ cd elc1
Philippe@pc-philippe /cygdrive/d/work/elc-dev/elc1 $ py.test
2010-09-27 11:30:59,592 5404 INFO elc.ElcLogger init_logging_local done
C:\Python26\lib\site-packages\py-1.3.4-py2.6.egg\py_plugin\pytest_default.py:57: DeprecationWarning: <class 'conftest.Directory'> was found in a conftest.py file, use pytest_collect hooks instead. (since version >1.1)
Directory = parent.config._getcollectclass('Directory', path)
Traceback (most recent call last):
File "c:\Python26\Scripts\py.test-script.py", line 8, in <module>
load_entry_point('py==1.3.4', 'console_scripts', 'py.test')()
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_cmdline\pytest.py", line 5, in main
raise SystemExit(py.test.cmdline.main(args))
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\cmdline.py", line 16, in main
colitems = config.getinitialnodes()
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\config.py", line 158, in getinitialnodes
return [self.getnode(arg) for arg in self.args]
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\config.py", line 173, in getnode
return self._rootcol.getbynames(names)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 388, in getbynames
for x in current._memocollect():
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 230, in _memocollect
return self._memoizedcall('_collected', self.collect)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 104, in _memoizedcall
res = function()
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 300, in collect
res = self.consider(path)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 309, in consider
if self.ihook.pytest_ignore_collect(path=path, config=self.config):
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\collect.py", line 21, in call_matching_hooks
return hookmethod.pcall(plugins, kwargs)
File "C:\Python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\pluginmanager.py", line 354, in pcall
return self.hookrelay._performcall(self.name, mc)
File "C:\Python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\pluginmanager.py", line 335, in _performcall
return multicall.execute()
File "C:\Python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\pluginmanager.py", line 244, in execute
res = method(
kwargs)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_plugin\pytest_default.py", line 32, in pytest_ignore_collect
ignore_paths = config.getconftest_pathlist("collect_ignore", path=path)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\config.py", line 195, in getconftest_pathlist
mod, relroots = self._conftest.rget_with_confmod(name, path)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\conftesthandle.py", line 88, in rget_with_confmod
modules = self.getconftestmodules(path)
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\conftesthandle.py", line 72, in getconftestmodules
clist.append(self.importconftest(conftestpath))
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_test\conftesthandle.py", line 108, in importconftest
mod = conftestpath.pyimport()
File "c:\python26\lib\site-packages\py-1.3.4-py2.6.egg\py_path\local.py", line 540, in pyimport
raise self.ImportMismatchError(modname, modfile, self)
py._path.local.ImportMismatchError: ('conftest', 'd:\work\elc-dev\Copy of git-linkchecker\conftest.py', local('d:\work\elc-dev\elc-memory\conftest.py'))
Philippe@pc-philippe /cygdrive/d/work/elc-dev/elc1 $
}}}

The errors reported below belong to other directories than elc1.

I have a conftest.py in elc1:

{{{

!python

Philippe@pc-philippe /cygdrive/d/work/elc-dev/elc1 $ cat conftest.py

this module is loaded by py.test before running the tests

import fix_path
import elcloginit

import tests.httpd_utils as httpd_utils
from tests.setupDbTestEnv import SetupDbTestEnv, envDict

collect_ignore = [ 'elc_linkchecker/linkchecker/' ]

DB_TEST_ENV = None

def pytest_namespace():
global DB_TEST_ENV
DB_TEST_ENV = SetupDbTestEnv()
envDict[ 'dbTestEnv' ] = DB_TEST_ENV
return envDict

def pytest_sessionstart( session ):
# print 'pytest_sessionstart'
DB_TEST_ENV.setup()

def pytest_sessionfinish( session, exitstatus ):
# print 'pytest_sessionfinish'
DB_TEST_ENV.teardown()
pass

}}}

Comments (2)

  1. Holger Krekel repo owner
    • changed status to open

    Thanks for reporting. I wonder if it was really 1.3.4 that introduced the problem - i am not aware of it.

    In any case, issue #109 gives a bit more details. We need to fix it up - i'll see to do that for the next release.

  2. Log in to comment