"""
Define errors that may be raised by xdoctest
"""
[docs]
class DoctestParseError(Exception):
"""
Exception raised when doctest code has an error.
"""
def __init__(self, msg, string=None, info=None, orig_ex=None):
"""
Args:
msg (str): error message
string (str | None): the string that failed
info (Any | None): extra information
orig_ex (Exception | None): The underlying exceptoin
"""
super(DoctestParseError, self).__init__(msg)
self.msg = msg
self.string = string
self.info = info
self.orig_ex = orig_ex
[docs]
class ExitTestException(Exception):
pass
[docs]
class IncompleteParseError(SyntaxError):
"""
Used when something goes wrong in the xdoctest parser
"""
pass
try:
import _pytest
import _pytest.outcomes
except ImportError: # nocover
# Define dummy skipped exception if pytest is not available
class _pytest(object): # type: ignore
class outcomes(object):
class Skipped(Exception):
pass