2
2
3
3
import py
4
4
from py ._code .code import TerminalRepr , ReprFileLocation
5
- doctest = py .std .doctest
6
5
7
6
def pytest_addoption (parser ):
8
7
group = parser .getgroup ("collect" )
@@ -39,16 +38,16 @@ def __init__(self, path, parent):
39
38
self .fspath = path
40
39
41
40
def repr_failure (self , excinfo ):
42
- if excinfo .errisinstance (doctest .DocTestFailure ):
41
+ if excinfo .errisinstance (py . std . doctest .DocTestFailure ):
43
42
doctestfailure = excinfo .value
44
43
example = doctestfailure .example
45
44
test = doctestfailure .test
46
45
filename = test .filename
47
46
lineno = test .lineno + example .lineno + 1
48
47
message = excinfo .type .__name__
49
48
reprlocation = ReprFileLocation (filename , lineno , message )
50
- checker = doctest .OutputChecker ()
51
- REPORT_UDIFF = doctest .REPORT_UDIFF
49
+ checker = py . std . doctest .OutputChecker ()
50
+ REPORT_UDIFF = py . std . doctest .REPORT_UDIFF
52
51
filelines = py .path .local (filename ).readlines (cr = 0 )
53
52
i = max (test .lineno , max (0 , lineno - 10 )) # XXX?
54
53
lines = []
@@ -58,7 +57,7 @@ def repr_failure(self, excinfo):
58
57
lines += checker .output_difference (example ,
59
58
doctestfailure .got , REPORT_UDIFF ).split ("\n " )
60
59
return ReprFailDoctest (reprlocation , lines )
61
- elif excinfo .errisinstance (doctest .UnexpectedException ):
60
+ elif excinfo .errisinstance (py . std . doctest .UnexpectedException ):
62
61
excinfo = py .code .ExceptionInfo (excinfo .value .exc_info )
63
62
return super (DoctestItem , self ).repr_failure (excinfo )
64
63
else :
@@ -70,12 +69,12 @@ def reportinfo(self):
70
69
class DoctestTextfile (DoctestItem ):
71
70
def runtest (self ):
72
71
if not self ._deprecated_testexecution ():
73
- failed , tot = doctest .testfile (
72
+ failed , tot = py . std . doctest .testfile (
74
73
str (self .fspath ), module_relative = False ,
75
74
raise_on_error = True , verbose = 0 )
76
75
77
76
class DoctestModule (DoctestItem ):
78
77
def runtest (self ):
79
78
module = self .fspath .pyimport ()
80
- failed , tot = doctest .testmod (
79
+ failed , tot = py . std . doctest .testmod (
81
80
module , raise_on_error = True , verbose = 0 )
0 commit comments