introduce --ignore option to ignore paths during collection
--HG-- branch : trunk
This commit is contained in:
parent
cd96e52144
commit
6d46efa87a
|
@ -1,6 +1,9 @@
|
|||
Changes between 1.1.2 and 1.1.1
|
||||
=====================================
|
||||
|
||||
- new option: --ignore will prevent specified path from collection.
|
||||
Can be specified multiple times.
|
||||
|
||||
- install 'py.test' and `py.which` with a ``-$VERSION`` suffix to
|
||||
disambiguate between Python3, python2.X, Jython and PyPy installed versions.
|
||||
|
||||
|
|
|
@ -394,8 +394,12 @@ class Directory(FSCollector):
|
|||
return l
|
||||
|
||||
def _ignore(self, path):
|
||||
ignore_paths = self.config.getconftest_pathlist("collect_ignore", path=path)
|
||||
return ignore_paths and path in ignore_paths
|
||||
ignore_paths = self.config.getconftest_pathlist("collect_ignore",
|
||||
path=path) or []
|
||||
excludeopt = self.config.getvalue("ignore")
|
||||
if excludeopt:
|
||||
ignore_paths.extend([py.path.local(x) for x in excludeopt])
|
||||
return path in ignore_paths
|
||||
# XXX more refined would be:
|
||||
if ignore_paths:
|
||||
for p in ignore_paths:
|
||||
|
|
|
@ -51,6 +51,8 @@ def pytest_addoption(parser):
|
|||
group._addoption('-x', '--exitfirst',
|
||||
action="store_true", dest="exitfirst", default=False,
|
||||
help="exit instantly on first error or failed test."),
|
||||
group.addoption("--ignore", action="append", metavar="path",
|
||||
help="ignore path during collection (multi-allowed).")
|
||||
group._addoption('-k',
|
||||
action="store", dest="keyword", default='',
|
||||
help="only run test items matching the given "
|
||||
|
|
|
@ -30,6 +30,15 @@ def test_plugin_already_exists(testdir):
|
|||
assert config.option.plugins == ['default']
|
||||
config.pluginmanager.do_configure(config)
|
||||
|
||||
def test_exclude(testdir):
|
||||
hellodir = testdir.mkdir("hello")
|
||||
hellodir.join("test_hello.py").write("x y syntaxerror")
|
||||
hello2dir = testdir.mkdir("hello2")
|
||||
hello2dir.join("test_hello2.py").write("x y syntaxerror")
|
||||
testdir.makepyfile(test_ok="def test_pass(): pass")
|
||||
result = testdir.runpytest("--ignore=hello", "--ignore=hello2")
|
||||
assert result.ret == 0
|
||||
assert result.stdout.fnmatch_lines(["*1 passed*"])
|
||||
|
||||
class TestDistOptions:
|
||||
def setup_method(self, method):
|
||||
|
|
Loading…
Reference in New Issue