Merge pull request #799 from pytest-dev/noconftest
Add a --noconftest option.
This commit is contained in:
commit
08613b621e
|
@ -65,6 +65,8 @@
|
||||||
- fix issue741: make running output from testdir.run copy/pasteable
|
- fix issue741: make running output from testdir.run copy/pasteable
|
||||||
Thanks Bruno Oliveira.
|
Thanks Bruno Oliveira.
|
||||||
|
|
||||||
|
- add a new ``--noconftest`` argument which ignores all ``conftest.py`` files.
|
||||||
|
|
||||||
2.7.2 (compared to 2.7.1)
|
2.7.2 (compared to 2.7.1)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ class PytestPluginManager(PluginManager):
|
||||||
self._path2confmods = {}
|
self._path2confmods = {}
|
||||||
self._conftestpath2mod = {}
|
self._conftestpath2mod = {}
|
||||||
self._confcutdir = None
|
self._confcutdir = None
|
||||||
|
self._noconftest = False
|
||||||
|
|
||||||
self.add_hookspecs(_pytest.hookspec)
|
self.add_hookspecs(_pytest.hookspec)
|
||||||
self.register(self)
|
self.register(self)
|
||||||
|
@ -212,6 +213,7 @@ class PytestPluginManager(PluginManager):
|
||||||
current = py.path.local()
|
current = py.path.local()
|
||||||
self._confcutdir = current.join(namespace.confcutdir, abs=True) \
|
self._confcutdir = current.join(namespace.confcutdir, abs=True) \
|
||||||
if namespace.confcutdir else None
|
if namespace.confcutdir else None
|
||||||
|
self._noconftest = namespace.noconftest
|
||||||
testpaths = namespace.file_or_dir
|
testpaths = namespace.file_or_dir
|
||||||
foundanchor = False
|
foundanchor = False
|
||||||
for path in testpaths:
|
for path in testpaths:
|
||||||
|
@ -236,6 +238,8 @@ class PytestPluginManager(PluginManager):
|
||||||
self._getconftestmodules(x)
|
self._getconftestmodules(x)
|
||||||
|
|
||||||
def _getconftestmodules(self, path):
|
def _getconftestmodules(self, path):
|
||||||
|
if self._noconftest:
|
||||||
|
return []
|
||||||
try:
|
try:
|
||||||
return self._path2confmods[path]
|
return self._path2confmods[path]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -54,6 +54,9 @@ def pytest_addoption(parser):
|
||||||
group.addoption('--confcutdir', dest="confcutdir", default=None,
|
group.addoption('--confcutdir', dest="confcutdir", default=None,
|
||||||
metavar="dir",
|
metavar="dir",
|
||||||
help="only load conftest.py's relative to specified dir.")
|
help="only load conftest.py's relative to specified dir.")
|
||||||
|
group.addoption('--noconftest', action="store_true",
|
||||||
|
dest="noconftest", default=False,
|
||||||
|
help="Don't load any conftest.py files.")
|
||||||
|
|
||||||
group = parser.getgroup("debugconfig",
|
group = parser.getgroup("debugconfig",
|
||||||
"test session debugging and configuration")
|
"test session debugging and configuration")
|
||||||
|
|
|
@ -24,6 +24,7 @@ def conftest_setinitial(conftest, args, confcutdir=None):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.file_or_dir = args
|
self.file_or_dir = args
|
||||||
self.confcutdir = str(confcutdir)
|
self.confcutdir = str(confcutdir)
|
||||||
|
self.noconftest = False
|
||||||
conftest._set_initial_conftests(Namespace())
|
conftest._set_initial_conftests(Namespace())
|
||||||
|
|
||||||
class TestConftestValueAccessGlobal:
|
class TestConftestValueAccessGlobal:
|
||||||
|
@ -162,6 +163,11 @@ def test_conftest_confcutdir(testdir):
|
||||||
result.stdout.fnmatch_lines(["*--xyz*"])
|
result.stdout.fnmatch_lines(["*--xyz*"])
|
||||||
assert 'warning: could not load initial' not in result.stdout.str()
|
assert 'warning: could not load initial' not in result.stdout.str()
|
||||||
|
|
||||||
|
def test_no_conftest(testdir):
|
||||||
|
testdir.makeconftest("assert 0")
|
||||||
|
result = testdir.runpytest("--noconftest")
|
||||||
|
assert result.ret == 0
|
||||||
|
|
||||||
def test_conftest_existing_resultlog(testdir):
|
def test_conftest_existing_resultlog(testdir):
|
||||||
x = testdir.mkdir("tests")
|
x = testdir.mkdir("tests")
|
||||||
x.join("conftest.py").write(py.code.Source("""
|
x.join("conftest.py").write(py.code.Source("""
|
||||||
|
|
Loading…
Reference in New Issue