avoid loading conftest files which are exactly the same content as a previously loaded conftest file
--HG-- branch : trunk
This commit is contained in:
parent
e5d09b771a
commit
74523a9d09
|
@ -1,11 +1,14 @@
|
||||||
Changes between 1.3.2 and 1.3.3a1
|
Changes between 1.3.2 and 1.3.3a1
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
|
- make conftest loading detect that a conftest file with the same
|
||||||
|
content was already loaded, avoids surprises in nested directory structures
|
||||||
|
that can be produced e.g. by Hudson. It alleviates the need to use
|
||||||
|
--confcutdir at all.
|
||||||
- fix terminal coloring for win32
|
- fix terminal coloring for win32
|
||||||
(thanks Michael Foord for reporting)
|
(thanks Michael Foord for reporting)
|
||||||
- fix weirdness: make terminal width detection work on stdout instead of stdin
|
- fix weirdness: make terminal width detection work on stdout instead of stdin
|
||||||
(thanks Armin Ronacher for reporting)
|
(thanks Armin Ronacher for reporting)
|
||||||
|
|
||||||
- remove trailing whitespace in all py/text files
|
- remove trailing whitespace in all py/text files
|
||||||
|
|
||||||
Changes between 1.3.1 and 1.3.2
|
Changes between 1.3.1 and 1.3.2
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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
|
||||||
|
@ -57,17 +58,23 @@ class Conftest(object):
|
||||||
if path is None:
|
if path is None:
|
||||||
raise ValueError("missing default confest.")
|
raise ValueError("missing default confest.")
|
||||||
dp = path.dirpath()
|
dp = path.dirpath()
|
||||||
if dp == path:
|
clist = []
|
||||||
clist = []
|
if dp != path:
|
||||||
else:
|
|
||||||
cutdir = self._confcutdir
|
cutdir = self._confcutdir
|
||||||
clist = self.getconftestmodules(dp)
|
|
||||||
if cutdir and path != cutdir and not path.relto(cutdir):
|
if cutdir and path != cutdir and not path.relto(cutdir):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
conftestpath = path.join("conftest.py")
|
conftestpath = path.join("conftest.py")
|
||||||
if conftestpath.check(file=1):
|
if conftestpath.check(file=1):
|
||||||
clist.append(self.importconftest(conftestpath))
|
key = conftestpath.computehash()
|
||||||
|
# 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)
|
||||||
self._path2confmods[path] = clist
|
self._path2confmods[path] = clist
|
||||||
# be defensive: avoid changes from caller side to
|
# be defensive: avoid changes from caller side to
|
||||||
# affect us by always returning a copy of the actual list
|
# affect us by always returning a copy of the actual list
|
||||||
|
|
|
@ -644,7 +644,7 @@ def pytest_report_header(config):
|
||||||
return ["line1", "line2"]""")
|
return ["line1", "line2"]""")
|
||||||
result = testdir.runpytest("a")
|
result = testdir.runpytest("a")
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*hello: info*",
|
|
||||||
"line1",
|
"line1",
|
||||||
"line2",
|
"line2",
|
||||||
|
"*hello: info*",
|
||||||
])
|
])
|
||||||
|
|
|
@ -149,6 +149,21 @@ 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")
|
||||||
|
|
||||||
@py.test.mark.multi(name='test tests whatever .dotdir'.split())
|
@py.test.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)
|
||||||
|
|
24
tox.ini
24
tox.ini
|
@ -7,10 +7,9 @@ distshare={toxworkdir}/distshare
|
||||||
sdistsrc={distshare}/py-*
|
sdistsrc={distshare}/py-*
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
changedir=testing
|
changedir=testing
|
||||||
commands=
|
commands=
|
||||||
py.test --confcutdir=.. -rfsxX \
|
py.test -rfsxX --junitxml={envlogdir}/junit-{envname}.xml --tools-on-path []
|
||||||
--junitxml={envlogdir}/junit-{envname}.xml --tools-on-path []
|
|
||||||
deps=
|
deps=
|
||||||
pexpect
|
pexpect
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
|
@ -21,7 +20,7 @@ deps=
|
||||||
{distshare}/py-*
|
{distshare}/py-*
|
||||||
{distshare}/pytest-xdist-*
|
{distshare}/pytest-xdist-*
|
||||||
commands=
|
commands=
|
||||||
py.test -n3 --confcutdir=.. -rfsxX \
|
py.test -n3 -rfsxX \
|
||||||
--junitxml={envlogdir}/junit-{envname}.xml --tools-on-path []
|
--junitxml={envlogdir}/junit-{envname}.xml --tools-on-path []
|
||||||
|
|
||||||
[testenv:py26]
|
[testenv:py26]
|
||||||
|
@ -29,19 +28,18 @@ basepython=python2.6
|
||||||
[testenv:doc]
|
[testenv:doc]
|
||||||
basepython=python
|
basepython=python
|
||||||
changedir={toxinidir}
|
changedir={toxinidir}
|
||||||
deps=docutils
|
deps=docutils
|
||||||
pygments
|
pygments
|
||||||
{distshare}/py-*
|
{distshare}/py-*
|
||||||
{distshare}/pytest-xdist-*
|
{distshare}/pytest-xdist-*
|
||||||
pytest-figleaf
|
pytest-figleaf
|
||||||
pytest-coverage
|
pytest-coverage
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-capturelog
|
pytest-capturelog
|
||||||
|
|
||||||
commands=
|
commands=
|
||||||
{envpython} bin-for-dist/makepluginlist.py
|
{envpython} bin-for-dist/makepluginlist.py
|
||||||
py.test [doc] -rsfxX --confcutdir=. \
|
py.test [doc] -rsfxX --junitxml={envlogdir}/junit-{envname}s.xml --forcegen
|
||||||
--junitxml={envlogdir}/junit-{envname}s.xml --forcegen
|
|
||||||
[testenv:py25]
|
[testenv:py25]
|
||||||
basepython=python2.5
|
basepython=python2.5
|
||||||
[testenv:py24]
|
[testenv:py24]
|
||||||
|
@ -55,7 +53,7 @@ deps=
|
||||||
changedir=testing
|
changedir=testing
|
||||||
basepython=jython
|
basepython=jython
|
||||||
commands=
|
commands=
|
||||||
{envpython} {envbindir}/py.test-jython --confcutdir=.. \
|
{envpython} {envbindir}/py.test-jython \
|
||||||
-rfsxX --junitxml={envlogdir}/junit-{envname}1.xml [io_ code]
|
-rfsxX --junitxml={envlogdir}/junit-{envname}1.xml [io_ code]
|
||||||
{envpython} {envbindir}/py.test-jython --confcutdir=.. \
|
{envpython} {envbindir}/py.test-jython \
|
||||||
-rfsxX --junitxml={envlogdir}/junit-{envname}2.xml acceptance_test.py plugin
|
-rfsxX --junitxml={envlogdir}/junit-{envname}2.xml acceptance_test.py plugin
|
||||||
|
|
Loading…
Reference in New Issue