[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 = '.. >>> '
|
||||
mod = py.std.types.ModuleType(self.fspath.purebasename)
|
||||
for line in s.split('\n'):
|
||||
line = line.strip()
|
||||
if line.startswith(prefix):
|
||||
exec py.code.Source(line[len(prefix):]).compile() in \
|
||||
mod.__dict__
|
||||
|
|
|
@ -5,6 +5,21 @@ from py.__.test.outcome import Skipped, Failed, Passed
|
|||
def setup_module(mod):
|
||||
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():
|
||||
# XXX get rid of the next line:
|
||||
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py'))
|
||||
|
|
Loading…
Reference in New Issue