[svn r38122] fix parsing of extra lines (to be executed)
--HG-- branch : trunk
This commit is contained in:
parent
461c0b6a54
commit
7213771cc9
|
@ -74,6 +74,7 @@ class DoctestText(py.test.Item):
|
||||||
prefix = '.. >>> '
|
prefix = '.. >>> '
|
||||||
mod = py.std.types.ModuleType(self.fspath.purebasename)
|
mod = py.std.types.ModuleType(self.fspath.purebasename)
|
||||||
for line in s.split('\n'):
|
for line in s.split('\n'):
|
||||||
|
line = line.strip()
|
||||||
if line.startswith(prefix):
|
if line.startswith(prefix):
|
||||||
exec py.code.Source(line[len(prefix):]).compile() in \
|
exec py.code.Source(line[len(prefix):]).compile() in \
|
||||||
mod.__dict__
|
mod.__dict__
|
||||||
|
|
|
@ -5,6 +5,21 @@ from py.__.test.outcome import Skipped, Failed, Passed
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
mod.tmpdir = py.test.ensuretemp('docdoctest')
|
mod.tmpdir = py.test.ensuretemp('docdoctest')
|
||||||
|
|
||||||
|
def test_doctest_extra_exec():
|
||||||
|
# XXX get rid of the next line:
|
||||||
|
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
|
||||||
|
xtxt = tmpdir.join('y.txt')
|
||||||
|
xtxt.write(py.code.Source("""
|
||||||
|
hello::
|
||||||
|
.. >>> raise ValueError
|
||||||
|
>>> None
|
||||||
|
"""))
|
||||||
|
config = py.test.config._reparse([xtxt])
|
||||||
|
session = config.initsession()
|
||||||
|
session.main()
|
||||||
|
l = session.getitemoutcomepairs(Failed)
|
||||||
|
assert len(l) == 1
|
||||||
|
|
||||||
def test_doctest_basic():
|
def test_doctest_basic():
|
||||||
# XXX get rid of the next line:
|
# XXX get rid of the next line:
|
||||||
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
|
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
|
||||||
|
|
Loading…
Reference in New Issue