1import types 2import unittest 3from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple, Type, Union 4 5class TestResults(NamedTuple): 6 failed: int 7 attempted: int 8 9OPTIONFLAGS_BY_NAME: Dict[str, int] 10 11def register_optionflag(name: str) -> int: ... 12 13DONT_ACCEPT_TRUE_FOR_1: int 14DONT_ACCEPT_BLANKLINE: int 15NORMALIZE_WHITESPACE: int 16ELLIPSIS: int 17SKIP: int 18IGNORE_EXCEPTION_DETAIL: int 19 20COMPARISON_FLAGS: int 21 22REPORT_UDIFF: int 23REPORT_CDIFF: int 24REPORT_NDIFF: int 25REPORT_ONLY_FIRST_FAILURE: int 26FAIL_FAST: int 27 28REPORTING_FLAGS: int 29 30BLANKLINE_MARKER: str 31ELLIPSIS_MARKER: str 32 33class Example: 34 source: str 35 want: str 36 exc_msg: Optional[str] 37 lineno: int 38 indent: int 39 options: Dict[int, bool] 40 def __init__( 41 self, 42 source: str, 43 want: str, 44 exc_msg: Optional[str] = ..., 45 lineno: int = ..., 46 indent: int = ..., 47 options: Optional[Dict[int, bool]] = ..., 48 ) -> None: ... 49 def __hash__(self) -> int: ... 50 51class DocTest: 52 examples: List[Example] 53 globs: Dict[str, Any] 54 name: str 55 filename: Optional[str] 56 lineno: Optional[int] 57 docstring: Optional[str] 58 def __init__( 59 self, 60 examples: List[Example], 61 globs: Dict[str, Any], 62 name: str, 63 filename: Optional[str], 64 lineno: Optional[int], 65 docstring: Optional[str], 66 ) -> None: ... 67 def __hash__(self) -> int: ... 68 def __lt__(self, other: DocTest) -> bool: ... 69 70class DocTestParser: 71 def parse(self, string: str, name: str = ...) -> List[Union[str, Example]]: ... 72 def get_doctest( 73 self, string: str, globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[int] 74 ) -> DocTest: ... 75 def get_examples(self, string: str, name: str = ...) -> List[Example]: ... 76 77class DocTestFinder: 78 def __init__( 79 self, verbose: bool = ..., parser: DocTestParser = ..., recurse: bool = ..., exclude_empty: bool = ... 80 ) -> None: ... 81 def find( 82 self, 83 obj: object, 84 name: Optional[str] = ..., 85 module: Union[None, bool, types.ModuleType] = ..., 86 globs: Optional[Dict[str, Any]] = ..., 87 extraglobs: Optional[Dict[str, Any]] = ..., 88 ) -> List[DocTest]: ... 89 90_Out = Callable[[str], Any] 91_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType] 92 93class DocTestRunner: 94 DIVIDER: str 95 optionflags: int 96 original_optionflags: int 97 tries: int 98 failures: int 99 test: DocTest 100 def __init__(self, checker: Optional[OutputChecker] = ..., verbose: Optional[bool] = ..., optionflags: int = ...) -> None: ... 101 def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ... 102 def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... 103 def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... 104 def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... 105 def run( 106 self, test: DocTest, compileflags: Optional[int] = ..., out: Optional[_Out] = ..., clear_globs: bool = ... 107 ) -> TestResults: ... 108 def summarize(self, verbose: Optional[bool] = ...) -> TestResults: ... 109 def merge(self, other: DocTestRunner) -> None: ... 110 111class OutputChecker: 112 def check_output(self, want: str, got: str, optionflags: int) -> bool: ... 113 def output_difference(self, example: Example, got: str, optionflags: int) -> str: ... 114 115class DocTestFailure(Exception): 116 test: DocTest 117 example: Example 118 got: str 119 def __init__(self, test: DocTest, example: Example, got: str) -> None: ... 120 121class UnexpectedException(Exception): 122 test: DocTest 123 example: Example 124 exc_info: _ExcInfo 125 def __init__(self, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... 126 127class DebugRunner(DocTestRunner): ... 128 129master: Optional[DocTestRunner] 130 131def testmod( 132 m: Optional[types.ModuleType] = ..., 133 name: Optional[str] = ..., 134 globs: Optional[Dict[str, Any]] = ..., 135 verbose: Optional[bool] = ..., 136 report: bool = ..., 137 optionflags: int = ..., 138 extraglobs: Optional[Dict[str, Any]] = ..., 139 raise_on_error: bool = ..., 140 exclude_empty: bool = ..., 141) -> TestResults: ... 142def testfile( 143 filename: str, 144 module_relative: bool = ..., 145 name: Optional[str] = ..., 146 package: Union[None, str, types.ModuleType] = ..., 147 globs: Optional[Dict[str, Any]] = ..., 148 verbose: Optional[bool] = ..., 149 report: bool = ..., 150 optionflags: int = ..., 151 extraglobs: Optional[Dict[str, Any]] = ..., 152 raise_on_error: bool = ..., 153 parser: DocTestParser = ..., 154 encoding: Optional[str] = ..., 155) -> TestResults: ... 156def run_docstring_examples( 157 f: object, 158 globs: Dict[str, Any], 159 verbose: bool = ..., 160 name: str = ..., 161 compileflags: Optional[int] = ..., 162 optionflags: int = ..., 163) -> None: ... 164def set_unittest_reportflags(flags: int) -> int: ... 165 166class DocTestCase(unittest.TestCase): 167 def __init__( 168 self, 169 test: DocTest, 170 optionflags: int = ..., 171 setUp: Optional[Callable[[DocTest], Any]] = ..., 172 tearDown: Optional[Callable[[DocTest], Any]] = ..., 173 checker: Optional[OutputChecker] = ..., 174 ) -> None: ... 175 def setUp(self) -> None: ... 176 def tearDown(self) -> None: ... 177 def runTest(self) -> None: ... 178 def format_failure(self, err: str) -> str: ... 179 def debug(self) -> None: ... 180 def id(self) -> str: ... 181 def __hash__(self) -> int: ... 182 def shortDescription(self) -> str: ... 183 184class SkipDocTestCase(DocTestCase): 185 def __init__(self, module: types.ModuleType) -> None: ... 186 def setUp(self) -> None: ... 187 def test_skip(self) -> None: ... 188 def shortDescription(self) -> str: ... 189 190class _DocTestSuite(unittest.TestSuite): ... 191 192def DocTestSuite( 193 module: Union[None, str, types.ModuleType] = ..., 194 globs: Optional[Dict[str, Any]] = ..., 195 extraglobs: Optional[Dict[str, Any]] = ..., 196 test_finder: Optional[DocTestFinder] = ..., 197 **options: Any, 198) -> _DocTestSuite: ... 199 200class DocFileCase(DocTestCase): 201 def id(self) -> str: ... 202 def format_failure(self, err: str) -> str: ... 203 204def DocFileTest( 205 path: str, 206 module_relative: bool = ..., 207 package: Union[None, str, types.ModuleType] = ..., 208 globs: Optional[Dict[str, Any]] = ..., 209 parser: DocTestParser = ..., 210 encoding: Optional[str] = ..., 211 **options: Any, 212) -> DocFileCase: ... 213def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... 214def script_from_examples(s: str) -> str: ... 215def testsource(module: Union[None, str, types.ModuleType], name: str) -> str: ... 216def debug_src(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... 217def debug_script(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... 218def debug(module: Union[None, str, types.ModuleType], name: str, pm: bool = ...) -> None: ... 219