massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 2 / unittest.pyi
1 # Stubs for unittest\r
2 \r
3 # Based on http://docs.python.org/2.7/library/unittest.html\r
4 \r
5 from typing import (Any, Callable, Dict, FrozenSet, Iterable, Iterator,\r
6                     List, NoReturn, Optional, overload, Pattern, Sequence, Set,\r
7                     Text, TextIO, Tuple, Type, TypeVar, Union)\r
8 from abc import abstractmethod, ABCMeta\r
9 import types\r
10 \r
11 _T = TypeVar('_T')\r
12 _FT = TypeVar('_FT')\r
13 \r
14 _ExceptionType = Union[Type[BaseException], Tuple[Type[BaseException], ...]]\r
15 _Regexp = Union[Text, Pattern[Text]]\r
16 \r
17 class Testable(metaclass=ABCMeta):\r
18     @abstractmethod\r
19     def run(self, result: 'TestResult') -> None: ...\r
20     @abstractmethod\r
21     def debug(self) -> None: ...\r
22     @abstractmethod\r
23     def countTestCases(self) -> int: ...\r
24 \r
25 # TODO ABC for test runners?\r
26 \r
27 class TestResult:\r
28     errors = ...  # type: List[Tuple[Testable, str]]\r
29     failures = ...  # type: List[Tuple[Testable, str]]\r
30     skipped = ...  # type: List[Tuple[Testable, str]]\r
31     expectedFailures = ...  # type: List[Tuple[Testable, str]]\r
32     unexpectedSuccesses = ...  # type: List[Testable]\r
33     shouldStop = ...  # type: bool\r
34     testsRun = ...  # type: int\r
35     buffer = ...  # type: bool\r
36     failfast = ...  # type: bool\r
37 \r
38     def wasSuccessful(self) -> bool: ...\r
39     def stop(self) -> None: ...\r
40     def startTest(self, test: Testable) -> None: ...\r
41     def stopTest(self, test: Testable) -> None: ...\r
42     def startTestRun(self) -> None: ...\r
43     def stopTestRun(self) -> None: ...\r
44     def addError(self, test: Testable,\r
45                   err: Tuple[type, Any, Any]) -> None: ...  # TODO\r
46     def addFailure(self, test: Testable,\r
47                     err: Tuple[type, Any, Any]) -> None: ...  # TODO\r
48     def addSuccess(self, test: Testable) -> None: ...\r
49     def addSkip(self, test: Testable, reason: str) -> None: ...\r
50     def addExpectedFailure(self, test: Testable, err: str) -> None: ...\r
51     def addUnexpectedSuccess(self, test: Testable) -> None: ...\r
52 \r
53 class _AssertRaisesBaseContext:\r
54     expected = ...  # type: Any\r
55     failureException = ...  # type: Type[BaseException]\r
56     obj_name = ...  # type: str\r
57     expected_regex = ...  # type: Pattern[str]\r
58 \r
59 class _AssertRaisesContext(_AssertRaisesBaseContext):\r
60     exception = ...  # type: Any # TODO precise type\r
61     def __enter__(self) -> _AssertRaisesContext: ...\r
62     def __exit__(self, exc_type, exc_value, tb) -> bool: ...\r
63 \r
64 class TestCase(Testable):\r
65     failureException = ...  # type: Type[BaseException]\r
66     longMessage = ...  # type: bool\r
67     maxDiff = ...  # type: Optional[int]\r
68     def __init__(self, methodName: str = ...) -> None: ...\r
69     def setUp(self) -> None: ...\r
70     def tearDown(self) -> None: ...\r
71     @classmethod\r
72     def setUpClass(cls) -> None: ...\r
73     @classmethod\r
74     def tearDownClass(cls) -> None: ...\r
75     def run(self, result: TestResult = ...) -> None: ...\r
76     def debug(self) -> None: ...\r
77     def assert_(self, expr: Any, msg: object = ...) -> None: ...\r
78     def failUnless(self, expr: Any, msg: object = ...) -> None: ...\r
79     def assertTrue(self, expr: Any, msg: object = ...) -> None: ...\r
80     def assertEqual(self, first: Any, second: Any,\r
81                     msg: object = ...) -> None: ...\r
82     def assertEquals(self, first: Any, second: Any,\r
83                      msg: object = ...) -> None: ...\r
84     def failUnlessEqual(self, first: Any, second: Any,\r
85                         msg: object = ...) -> None: ...\r
86     def assertNotEqual(self, first: Any, second: Any,\r
87                        msg: object = ...) -> None: ...\r
88     def assertNotEquals(self, first: Any, second: Any,\r
89                         msg: object = ...) -> None: ...\r
90     def failIfEqual(self, first: Any, second: Any,\r
91                     msg: object = ...) -> None: ...\r
92     def assertAlmostEqual(self, first: float, second: float, places: int = ...,\r
93                           msg: object = ...,\r
94                           delta: float = ...) -> None: ...\r
95     def assertAlmostEquals(self, first: float, second: float, places: int = ...,\r
96                            msg: object = ...,\r
97                            delta: float = ...) -> None: ...\r
98     def failUnlessAlmostEqual(self, first: float, second: float, places: int = ...,\r
99                               msg: object = ...) -> None: ...\r
100     def assertNotAlmostEqual(self, first: float, second: float, places: int = ...,\r
101                              msg: object = ...,\r
102                              delta: float = ...) -> None: ...\r
103     def assertNotAlmostEquals(self, first: float, second: float, places: int = ...,\r
104                               msg: object = ...,\r
105                               delta: float = ...) -> None: ...\r
106     def failIfAlmostEqual(self, first: float, second: float, places: int = ...,\r
107                           msg: object = ...,\r
108                           delta: float = ...) -> None: ...\r
109     def assertGreater(self, first: Any, second: Any,\r
110                       msg: object = ...) -> None: ...\r
111     def assertGreaterEqual(self, first: Any, second: Any,\r
112                            msg: object = ...) -> None: ...\r
113     def assertMultiLineEqual(self, first: str, second: str,\r
114                              msg: object = ...) -> None: ...\r
115     def assertSequenceEqual(self, first: Sequence[Any], second: Sequence[Any],\r
116                             msg: object = ..., seq_type: type = ...) -> None: ...\r
117     def assertListEqual(self, first: List[Any], second: List[Any],\r
118                         msg: object = ...) -> None: ...\r
119     def assertTupleEqual(self, first: Tuple[Any, ...], second: Tuple[Any, ...],\r
120                          msg: object = ...) -> None: ...\r
121     def assertSetEqual(self, first: Union[Set[Any], FrozenSet[Any]],\r
122                        second: Union[Set[Any], FrozenSet[Any]], msg: object = ...) -> None: ...\r
123     def assertDictEqual(self, first: Dict[Any, Any], second: Dict[Any, Any],\r
124                         msg: object = ...) -> None: ...\r
125     def assertLess(self, first: Any, second: Any,\r
126                    msg: object = ...) -> None: ...\r
127     def assertLessEqual(self, first: Any, second: Any,\r
128                         msg: object = ...) -> None: ...\r
129     @overload\r
130     def assertRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...\r
131     @overload\r
132     def assertRaises(self, exception: _ExceptionType) -> _AssertRaisesContext: ...\r
133     @overload\r
134     def assertRaisesRegexp(self, exception: _ExceptionType, regexp: _Regexp, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...\r
135     @overload\r
136     def assertRaisesRegexp(self, exception: _ExceptionType, regexp: _Regexp) -> _AssertRaisesContext: ...\r
137     def assertRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ...\r
138     def assertNotRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ...\r
139     def assertItemsEqual(self, first: Iterable[Any], second: Iterable[Any], msg: object = ...) -> None: ...\r
140     def assertDictContainsSubset(self, expected: Dict[Any, Any], actual: Dict[Any, Any], msg: object = ...) -> None: ...\r
141     def addTypeEqualityFunc(self, typeobj: type, function: Callable[..., None]) -> None: ...\r
142     @overload\r
143     def failUnlessRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...\r
144     @overload\r
145     def failUnlessRaises(self, exception: _ExceptionType) -> _AssertRaisesContext: ...\r
146     def failIf(self, expr: Any, msg: object = ...) -> None: ...\r
147     def assertFalse(self, expr: Any, msg: object = ...) -> None: ...\r
148     def assertIs(self, first: object, second: object,\r
149                  msg: object = ...) -> None: ...\r
150     def assertIsNot(self, first: object, second: object,\r
151                     msg: object = ...) -> None: ...\r
152     def assertIsNone(self, expr: Any, msg: object = ...) -> None: ...\r
153     def assertIsNotNone(self, expr: Any, msg: object = ...) -> None: ...\r
154     def assertIn(self, first: _T, second: Iterable[_T],\r
155                  msg: object = ...) -> None: ...\r
156     def assertNotIn(self, first: _T, second: Iterable[_T],\r
157                     msg: object = ...) -> None: ...\r
158     def assertIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]],\r
159                          msg: object = ...) -> None: ...\r
160     def assertNotIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]],\r
161                             msg: object = ...) -> None: ...\r
162     def fail(self, msg: object = ...) -> NoReturn: ...\r
163     def countTestCases(self) -> int: ...\r
164     def defaultTestResult(self) -> TestResult: ...\r
165     def id(self) -> str: ...\r
166     def shortDescription(self) -> str: ...  # May return None\r
167     def addCleanup(function: Any, *args: Any, **kwargs: Any) -> None: ...\r
168     def doCleanups(self) -> bool: ...\r
169     def skipTest(self, reason: Any) -> None: ...\r
170 \r
171 class FunctionTestCase(Testable):\r
172     def __init__(self, testFunc: Callable[[], None],\r
173                  setUp: Optional[Callable[[], None]] = ...,\r
174                  tearDown: Optional[Callable[[], None]] = ...,\r
175                  description: Optional[str] = ...) -> None: ...\r
176     def run(self, result: TestResult) -> None: ...\r
177     def debug(self) -> None: ...\r
178     def countTestCases(self) -> int: ...\r
179 \r
180 class TestSuite(Testable):\r
181     def __init__(self, tests: Iterable[Testable] = ...) -> None: ...\r
182     def addTest(self, test: Testable) -> None: ...\r
183     def addTests(self, tests: Iterable[Testable]) -> None: ...\r
184     def run(self, result: TestResult) -> None: ...\r
185     def debug(self) -> None: ...\r
186     def countTestCases(self) -> int: ...\r
187     def __iter__(self) -> Iterator[Testable]: ...\r
188 \r
189 class TestLoader:\r
190     testMethodPrefix = ...  # type: str\r
191     sortTestMethodsUsing = ...  # type: Optional[Callable[[str, str], int]]\r
192     suiteClass = ...  # type: Callable[[List[TestCase]], TestSuite]\r
193     def loadTestsFromTestCase(self,\r
194                               testCaseClass: Type[TestCase]) -> TestSuite: ...\r
195     def loadTestsFromModule(self, module: types.ModuleType = ...,\r
196                             use_load_tests: bool = ...) -> TestSuite: ...\r
197     def loadTestsFromName(self, name: str = ...,\r
198                           module: Optional[types.ModuleType] = ...) -> TestSuite: ...\r
199     def loadTestsFromNames(self, names: List[str] = ...,\r
200                           module: Optional[types.ModuleType] = ...) -> TestSuite: ...\r
201     def discover(self, start_dir: str, pattern: str = ...,\r
202                  top_level_dir: Optional[str] = ...) -> TestSuite: ...\r
203     def getTestCaseNames(self, testCaseClass: Type[TestCase] = ...) -> List[str]: ...\r
204 \r
205 defaultTestLoader = ...  # type: TestLoader\r
206 \r
207 class TextTestResult(TestResult):\r
208     def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ...\r
209 \r
210 class TextTestRunner:\r
211     def __init__(self, stream: Optional[TextIO] = ..., descriptions: bool = ...,\r
212                  verbosity: int = ..., failfast: bool = ..., buffer: bool = ...,\r
213                  resultclass: Optional[Type[TestResult]] = ...) -> None: ...\r
214     def _makeResult(self) -> TestResult: ...\r
215 \r
216 class SkipTest(Exception):\r
217     ...\r
218 \r
219 # TODO precise types\r
220 def skipUnless(condition: Any, reason: Union[str, unicode]) -> Any: ...\r
221 def skipIf(condition: Any, reason: Union[str, unicode]) -> Any: ...\r
222 def expectedFailure(func: _FT) -> _FT: ...\r
223 def skip(reason: Union[str, unicode]) -> Any: ...\r
224 \r
225 # not really documented\r
226 class TestProgram:\r
227     result = ...  # type: TestResult\r
228 \r
229 def main(module: str = ..., defaultTest: Optional[str] = ...,\r
230          argv: Optional[Sequence[str]] = ...,\r
231          testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ...,\r
232          testLoader: TestLoader = ..., exit: bool = ..., verbosity: int = ...,\r
233          failfast: Optional[bool] = ..., catchbreak: Optional[bool] = ...,\r
234          buffer: Optional[bool] = ...) -> TestProgram: ...\r
235 \r
236 def load_tests(loader: TestLoader, tests: TestSuite, pattern: Optional[Text]) -> TestSuite: ...\r
237 \r
238 def installHandler() -> None: ...\r
239 def registerResult(result: TestResult) -> None: ...\r
240 def removeResult(result: TestResult) -> bool: ...\r
241 @overload\r
242 def removeHandler() -> None: ...\r
243 @overload\r
244 def removeHandler(function: Callable[..., Any]) -> Callable[..., Any]: ...\r
245 \r
246 # private but occasionally used\r
247 util = ...  # type: types.ModuleType\r