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