def test_simple_docteststring():
testitem = DoctestText(name="dummy", parent=None)
testitem._setcontent("""
>>> i = 0
>>> i + 1
1
""")
-> res = testitem.run()
assert res is None
def run(self):
mod = py.std.types.ModuleType(self.name)
#for line in s.split('\n'):
# if line.startswith(prefix):
# exec py.code.Source(line[len(prefix):]).compile() in mod.__dict__
# line = ""
# else:
# l.append(line)
-> self.execute(mod, self._content)
def execute(self, mod, docstring):
mod.__doc__ = docstring
-> failed, tot = py.compat.doctest.testmod(mod, verbose=1)
if failed:
py.test.fail("doctest %s: %s failed out of %s" %(
self.fspath, failed, tot))