parent
0ea8dc0d40
commit
1bdf71730a
1
AUTHORS
1
AUTHORS
|
@ -45,6 +45,7 @@ Jaap Broekhuizen
|
||||||
Jan Balster
|
Jan Balster
|
||||||
Janne Vanhala
|
Janne Vanhala
|
||||||
Jason R. Coombs
|
Jason R. Coombs
|
||||||
|
Joshua Bronson
|
||||||
Jurko Gospodnetić
|
Jurko Gospodnetić
|
||||||
Katarzyna Jachim
|
Katarzyna Jachim
|
||||||
Kevin Cox
|
Kevin Cox
|
||||||
|
|
|
@ -7,6 +7,9 @@ New Features
|
||||||
* New `pytest.mark.skip` mark, which unconditional skips marked tests.
|
* New `pytest.mark.skip` mark, which unconditional skips marked tests.
|
||||||
Thanks Michael Aquilina for the complete PR.
|
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
|
* New `-rp` and `-rP` reporting options give the summary and full output
|
||||||
of passing tests, respectively. Thanks to David Vierra for the PR.
|
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",
|
help="run doctests in all .py modules",
|
||||||
dest="doctestmodules")
|
dest="doctestmodules")
|
||||||
group.addoption("--doctest-glob",
|
group.addoption("--doctest-glob",
|
||||||
action="append", default=["test*.txt"], metavar="pat",
|
action="append", default=[], metavar="pat",
|
||||||
help="doctests file matching pattern, default: test*.txt",
|
help="doctests file matching pattern, default: test*.txt",
|
||||||
dest="doctestglob")
|
dest="doctestglob")
|
||||||
group.addoption("--doctest-ignore-import-errors",
|
group.addoption("--doctest-ignore-import-errors",
|
||||||
|
@ -36,7 +36,7 @@ def pytest_collect_file(path, parent):
|
||||||
def _is_doctest(config, path, parent):
|
def _is_doctest(config, path, parent):
|
||||||
if path.ext in ('.txt', '.rst') and parent.session.isinitpath(path):
|
if path.ext in ('.txt', '.rst') and parent.session.isinitpath(path):
|
||||||
return True
|
return True
|
||||||
globs = config.getoption("doctestglob")
|
globs = config.getoption("doctestglob") or ['test*.txt']
|
||||||
for glob in globs:
|
for glob in globs:
|
||||||
if path.check(fnmatch=glob):
|
if path.check(fnmatch=glob):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -8,7 +8,10 @@ can change the pattern by issuing::
|
||||||
|
|
||||||
py.test --doctest-glob='*.rst'
|
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
|
from docstrings in all python modules (including regular
|
||||||
python test modules)::
|
python test modules)::
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class TestDoctests:
|
||||||
reprec.assertoutcome(failed=1)
|
reprec.assertoutcome(failed=1)
|
||||||
|
|
||||||
def test_new_pattern(self, testdir):
|
def test_new_pattern(self, testdir):
|
||||||
p = testdir.maketxtfile(xdoc ="""
|
p = testdir.maketxtfile(xdoc="""
|
||||||
>>> x = 1
|
>>> x = 1
|
||||||
>>> x == 1
|
>>> x == 1
|
||||||
False
|
False
|
||||||
|
@ -95,6 +95,36 @@ class TestDoctests:
|
||||||
reprec = testdir.inline_run(p, "--doctest-glob=x*.txt")
|
reprec = testdir.inline_run(p, "--doctest-glob=x*.txt")
|
||||||
reprec.assertoutcome(failed=1)
|
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):
|
def test_doctest_unexpected_exception(self, testdir):
|
||||||
testdir.maketxtfile("""
|
testdir.maketxtfile("""
|
||||||
>>> i = 0
|
>>> i = 0
|
||||||
|
|
Loading…
Reference in New Issue