remove same-conftest.py detection - does more harm than good

(see mail from Ralf Schmitt on py-dev)
This commit is contained in:
holger krekel 2011-01-11 15:54:47 +01:00
parent 8f5d837ef6
commit 170c78cef9
3 changed files with 3 additions and 24 deletions

View File

@ -1,6 +1,8 @@
Changes between 2.0.0 and 2.0.1.devX Changes between 2.0.0 and 2.0.1.devX
---------------------------------------------- ----------------------------------------------
- remove somewhat surprising "same-conftest" detection because
it ignores conftest.py when they appear in several subdirs.
- improve assertions ("not in"), thanks Floris - improve assertions ("not in"), thanks Floris
- improve behaviour/warnings when running on top of "python -OO" - improve behaviour/warnings when running on top of "python -OO"
(assertions and docstrings are turned off, leading to potential (assertions and docstrings are turned off, leading to potential

View File

@ -125,7 +125,6 @@ class Conftest(object):
self._onimport = onimport self._onimport = onimport
self._conftestpath2mod = {} self._conftestpath2mod = {}
self._confcutdir = confcutdir self._confcutdir = confcutdir
self._md5cache = {}
def setinitial(self, args): def setinitial(self, args):
""" try to find a first anchor path for looking up global values """ try to find a first anchor path for looking up global values
@ -179,14 +178,7 @@ class Conftest(object):
else: else:
conftestpath = path.join("conftest.py") conftestpath = path.join("conftest.py")
if conftestpath.check(file=1): if conftestpath.check(file=1):
key = conftestpath.computehash() clist.append(self.importconftest(conftestpath))
# XXX logging about conftest loading
if key not in self._md5cache:
clist.append(self.importconftest(conftestpath))
self._md5cache[key] = conftestpath
else:
# use some kind of logging
print ("WARN: not loading %s" % conftestpath)
clist[:0] = self.getconftestmodules(dp) clist[:0] = self.getconftestmodules(dp)
self._path2confmods[path] = clist self._path2confmods[path] = clist
# be defensive: avoid changes from caller side to # be defensive: avoid changes from caller side to

View File

@ -170,21 +170,6 @@ def test_setinitial_confcut(testdir):
assert conftest.getconftestmodules(sub) == [] assert conftest.getconftestmodules(sub) == []
assert conftest.getconftestmodules(conf.dirpath()) == [] assert conftest.getconftestmodules(conf.dirpath()) == []
def test_conftest_samecontent_detection(testdir):
conf = testdir.makeconftest("x=3")
p = testdir.mkdir("x")
conf.copy(p.join("conftest.py"))
conftest = Conftest()
conftest.setinitial([p])
l = conftest.getconftestmodules(p)
assert len(l) == 1
assert l[0].__file__ == p.join("conftest.py")
p2 = p.mkdir("y")
conf.copy(p2.join("conftest.py"))
l = conftest.getconftestmodules(p2)
assert len(l) == 1
assert l[0].__file__ == p.join("conftest.py")
@pytest.mark.multi(name='test tests whatever .dotdir'.split()) @pytest.mark.multi(name='test tests whatever .dotdir'.split())
def test_setinitial_conftest_subdirs(testdir, name): def test_setinitial_conftest_subdirs(testdir, name):
sub = testdir.mkdir(name) sub = testdir.mkdir(name)