diff --git a/pytest/plugin/doctest.py b/pytest/plugin/doctest.py index b34475647..26f51dece 100644 --- a/pytest/plugin/doctest.py +++ b/pytest/plugin/doctest.py @@ -2,7 +2,6 @@ import py from py._code.code import TerminalRepr, ReprFileLocation -doctest = py.std.doctest def pytest_addoption(parser): group = parser.getgroup("collect") @@ -39,7 +38,7 @@ class DoctestItem(py.test.collect.Item): self.fspath = path def repr_failure(self, excinfo): - if excinfo.errisinstance(doctest.DocTestFailure): + if excinfo.errisinstance(py.std.doctest.DocTestFailure): doctestfailure = excinfo.value example = doctestfailure.example test = doctestfailure.test @@ -47,8 +46,8 @@ class DoctestItem(py.test.collect.Item): lineno = test.lineno + example.lineno + 1 message = excinfo.type.__name__ reprlocation = ReprFileLocation(filename, lineno, message) - checker = doctest.OutputChecker() - REPORT_UDIFF = doctest.REPORT_UDIFF + checker = py.std.doctest.OutputChecker() + REPORT_UDIFF = py.std.doctest.REPORT_UDIFF filelines = py.path.local(filename).readlines(cr=0) i = max(test.lineno, max(0, lineno - 10)) # XXX? lines = [] @@ -58,7 +57,7 @@ class DoctestItem(py.test.collect.Item): lines += checker.output_difference(example, doctestfailure.got, REPORT_UDIFF).split("\n") return ReprFailDoctest(reprlocation, lines) - elif excinfo.errisinstance(doctest.UnexpectedException): + elif excinfo.errisinstance(py.std.doctest.UnexpectedException): excinfo = py.code.ExceptionInfo(excinfo.value.exc_info) return super(DoctestItem, self).repr_failure(excinfo) else: @@ -70,12 +69,12 @@ class DoctestItem(py.test.collect.Item): class DoctestTextfile(DoctestItem): def runtest(self): if not self._deprecated_testexecution(): - failed, tot = doctest.testfile( + failed, tot = py.std.doctest.testfile( str(self.fspath), module_relative=False, raise_on_error=True, verbose=0) class DoctestModule(DoctestItem): def runtest(self): module = self.fspath.pyimport() - failed, tot = doctest.testmod( + failed, tot = py.std.doctest.testmod( module, raise_on_error=True, verbose=0)