Commit Graph

30 Commits

Author SHA1 Message Date
Shantanu
6ff5b88ca7 typeshed: remove crufty comments (#4699)
Co-authored-by: hauntsaninja <>
2020-10-23 09:40:06 +02:00
Jelle Zijlstra
5f9fd3d127 upgrade black version (#4486)
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Rebecca Chen
e0151e724a Make unittest.FunctionTestCase inherit from TestCase in Python 2. (#3597)
This makes the pyi file match the implementation:
249706c1fb/Lib/unittest/case.py (L1019).

I also removed a now-redundant `run` method from FunctionTestCase
because the mypy test complained about it having a different signature
from TestCase.run().

Context:
https://github.com/python/typeshed/pull/3550#issuecomment-572702513.
2020-01-09 13:04:08 -08:00
Jan Verbeek
a705d59479 Add undocumented methods and make types more specific in 2/unittest (#3550) 2019-12-19 18:17:14 +01:00
Diego Elio Pettenò
99a6fb3108 Add the (deprecated) assertDictContainsSubset() to TestCase. (#3437)
Until this is removed from the standard library, it probably should stay in the typing.

Also update both 2 and 3 definitions to use Mapping[Any, Any], rather than Dict[Any, Any].
2019-11-04 08:10:45 -08:00
Diego Elio Pettenò
7e27bf6bde Allow datetime() with a delta=timedelta() in assert(Not)AlmostEqual(s). (#3426)
While the documentation does not seem to make this particularly
obvious, it is allowed.
2019-11-02 22:35:09 -07:00
Jan Szopinski
bf2d51742b unittest: Add overloads to assert(Not)AlmostEqual(s) (#2901) 2019-05-05 15:15:17 -04:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Richard Levasseur
4122a70648 Add some private methods to unittest (#2494)
This adds a few stubs that are used by absl-py, and, without them, cause
type checker errors under Pytype:
 * TestCase._formatMessage
 * TestCase._testMethodName
 * TestCase._getAssertEqualityFunc
 * TestProgram.runTests
2018-10-01 20:18:26 -07:00
Jelle Zijlstra
8b9e4c378a fix module argument to unittest.main (#2403) 2018-09-10 11:04:05 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau
6a18bd3ec2 Add missing self to TestCase.addCleanup() (#2301) 2018-07-02 12:12:59 -07:00
Jelle Zijlstra
0f425db197 fix types for unittest.TestLoader.loadTestsFrom* methods (#2042)
Fixes #2008.
2018-04-12 12:29:32 -07:00
rchen152
38dc8f5a6a Switch usages of mypy_extensions.NoReturn over to typing.NoReturn. (#1942)
* Change mypy_extensions.NoReturn to typing.NoReturn everywhere.
2018-03-05 12:42:29 -08:00
rchen152
066c434410 Improve the unittest stubs. (#1927)
* Improvements to stdlib/2/unittest.pyi

* Adds a bunch of missing things.
* Fixes the signatures of assertRaises and failUnlessRaises.
* Corrects the name of a TestCase subclass from CallableTestCase
  to FunctionTestCase.
* Makes defaultTestLoader an instance of TestLoader, as it should
  be, rather than an alias. Based on https://docs.python.org/2/library/unittest.html and
  https://github.com/python/cpython/tree/2.7/Lib/unittest.

* Improvements to stdlib/3/unittest/__init__.pyi

* The constructor arguments to TextTestResult are all required.
* There is a module-level load_tests() function.
* removeResult() returns a bool. Based on https://docs.python.org/3/library/unittest.html and
  https://github.com/python/cpython/tree/master/Lib/unittest.
2018-02-27 06:46:10 -08:00
Matt Bogosian
afc84c119c Add TestCase.longMessage to stdlib/2/unittest.pyi (#1875)
Fixes #1874.
2018-02-11 16:16:35 -08:00
rchen152
66e5863ead Change the return type of unittest.TestCase.fail() to NoReturn (#1843)
* Change the return type of unittest.TestCase.fail() to NoReturn

* Import mypy_extensions.NoReturn instead of typing.NoReturn
2018-01-26 14:28:37 -08:00
rchen152
8753fc78df Add setUpClass and tearDownClass to unittest.TestCase in Python 2 stub (#1760) 2017-11-21 16:39:11 -08:00
Matěj Cepl
6f0c929658 Fix unittest.main() parameters. (#1351) 2017-05-27 14:40:55 -07:00
Guido van Rossum
359c8cc313 Remove all mention of 'module' from typeshed. (#1156)
This depends on python/mypy#3107.
2017-04-13 08:40:52 -07:00
jkleint
433b1b2ebc TestCase.assertSetEqual() should accept frozenset (#1063)
This declares the method to take the union of Set and FrozenSet
rather than AbstractSet since that is where `difference()`
(used by `assertSetEqual()`) is defined.
2017-03-21 23:10:19 -07:00
Matthias Kramm
6855a20a51 add TestCase.failureException (#907) 2017-01-31 14:37:52 -08:00
Lucas Wiman
7c93bb07e1 Update annotations for unittest.skip* methods. (#877) 2017-01-29 20:33:49 -08:00
Eric Moyer
2580702036 Match py2 assert*IsInstance with isinstance
The python2 unittest `assertIsInstance` and `assertNotIsInstance` stub
did not allow using a tuple of classes, but that behavior is [in the
documentation][1]. This commit copies the type stub for the isinstance
built-in to the stubs for `assertIsInstance` and `assertNotIsInstance`

I made this commit in response to @gvanrossum's request in
python/typeshed#802 (which fixed this issue for python 3) that I apply
the same fix to python 2.

[1]: https://docs.python.org/2.7/library/unittest.html#unittest.TestCase.assertNotIsInstance
2017-01-12 09:29:23 -08:00
Lukasz Langa
bacd6c0aed Add missing Set imports. 2016-12-21 01:17:55 -08:00
Lukasz Langa
c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Guido van Rossum
cb97bb54c0 Move 2.7 to 2 (#635)
Closes #579.
2016-10-26 16:24:49 -07:00