parent
0ea8dc0d40
commit
1bdf71730a
1
AUTHORS
1
AUTHORS
|
@ -45,6 +45,7 @@ Jaap Broekhuizen
|
|||
Jan Balster
|
||||
Janne Vanhala
|
||||
Jason R. Coombs
|
||||
Joshua Bronson
|
||||
Jurko Gospodnetić
|
||||
Katarzyna Jachim
|
||||
Kevin Cox
|
||||
|
|
|
@ -7,6 +7,9 @@ New Features
|
|||
* New `pytest.mark.skip` mark, which unconditional skips marked tests.
|
||||
Thanks Michael Aquilina for the complete PR.
|
||||
|
||||
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
||||
Thanks Joshua Bronson and Bruno Oliveira for the PR.
|
||||
|
||||
* New `-rp` and `-rP` reporting options give the summary and full output
|
||||
of passing tests, respectively. Thanks to David Vierra for the PR.
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def pytest_addoption(parser):
|
|||
help="run doctests in all .py modules",
|
||||
dest="doctestmodules")
|
||||
group.addoption("--doctest-glob",
|
||||
action="append", default=["test*.txt"], metavar="pat",
|
||||
action="append", default=[], metavar="pat",
|
||||
help="doctests file matching pattern, default: test*.txt",
|
||||
dest="doctestglob")
|
||||
group.addoption("--doctest-ignore-import-errors",
|
||||
|
@ -36,7 +36,7 @@ def pytest_collect_file(path, parent):
|
|||
def _is_doctest(config, path, parent):
|
||||
if path.ext in ('.txt', '.rst') and parent.session.isinitpath(path):
|
||||
return True
|
||||
globs = config.getoption("doctestglob")
|
||||
globs = config.getoption("doctestglob") or ['test*.txt']
|
||||
for glob in globs:
|
||||
if path.check(fnmatch=glob):
|
||||
return True
|
||||
|
|
|
@ -8,7 +8,10 @@ can change the pattern by issuing::
|
|||
|
||||
py.test --doctest-glob='*.rst'
|
||||
|
||||
on the command line. You can also trigger running of doctests
|
||||
on the command line. Since version ``2.9``, ``--doctest-glob``
|
||||
can be given multiple times in the command-line.
|
||||
|
||||
You can also trigger running of doctests
|
||||
from docstrings in all python modules (including regular
|
||||
python test modules)::
|
||||
|
||||
|
|
|
@ -95,6 +95,36 @@ class TestDoctests:
|
|||
reprec = testdir.inline_run(p, "--doctest-glob=x*.txt")
|
||||
reprec.assertoutcome(failed=1)
|
||||
|
||||
def test_multiple_patterns(self, testdir):
|
||||
"""Test support for multiple --doctest-glob arguments (#1255).
|
||||
"""
|
||||
testdir.maketxtfile(xdoc="""
|
||||
>>> 1
|
||||
1
|
||||
""")
|
||||
testdir.makefile('.foo', test="""
|
||||
>>> 1
|
||||
1
|
||||
""")
|
||||
testdir.maketxtfile(test_normal="""
|
||||
>>> 1
|
||||
1
|
||||
""")
|
||||
expected = set(['xdoc.txt', 'test.foo', 'test_normal.txt'])
|
||||
assert set(x.basename for x in testdir.tmpdir.listdir()) == expected
|
||||
args = ["--doctest-glob=xdoc*.txt", "--doctest-glob=*.foo"]
|
||||
result = testdir.runpytest(*args)
|
||||
result.stdout.fnmatch_lines([
|
||||
'*test.foo *',
|
||||
'*xdoc.txt *',
|
||||
'*2 passed*',
|
||||
])
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines([
|
||||
'*test_normal.txt *',
|
||||
'*1 passed*',
|
||||
])
|
||||
|
||||
def test_doctest_unexpected_exception(self, testdir):
|
||||
testdir.maketxtfile("""
|
||||
>>> i = 0
|
||||
|
|
Loading…
Reference in New Issue