Commit Graph

43 Commits

Author SHA1 Message Date
Alex Waygood
257e287fec Stdlib: correct many parameter names (#9815) 2023-03-04 09:53:12 +00:00
Alex Waygood
6ba28ae547 Remove unused type: ignore comments (#9801) 2023-02-23 12:59:50 -08:00
Alex Waygood
4273a83bb7 unittest: Use a recursive type alias for assertIsInstance (#9770) 2023-02-20 15:35:50 +00:00
Alex Waygood
9ed39d8796 Use typing_extensions.Self in the stdlib (#9694) 2023-02-09 09:12:13 +00:00
Alex Waygood
0ef9c3f8e8 Enable flake8-pyi's Y037 (#9686) 2023-02-06 19:01:02 -08:00
Alex Waygood
33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00
Jelle Zijlstra
ddfaca3200 stdlib: add argument default values (#9501) 2023-01-18 09:37:34 +01:00
Terrance
4661af99c3 Annotate unittest.TestCase.skipTest() as no-return (#9352)
Annotate unittest.TestCase.skipTest() as no-return

This method unconditionally raises unittest.SkipTest, which ends a test
method early.  unittest.TestCase.fail() works similarly, and is already
annotated with NoReturn to indicate this behaviour.
2022-12-11 18:07:09 +00:00
Jelle Zijlstra
1f7648976c unittest: cannot use bytes regexes (#9107)
```
>>> from unittest.case import TestCase
>>> c = TestCase()
>>> with c.assertRaisesRegex(Exception, b"x"): 1/0
...
ZeroDivisionError: division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/case.py", line 274, in __exit__
    if not expected_regex.search(str(exc_value)):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot use a bytes pattern on a string-like object
```
2022-11-05 14:14:53 -07:00
Shane Harvey
1a2914adc5 Use Callable[..., Any] instead of Callable[..., object] in unittest (#8399) 2022-09-21 13:46:38 +01:00
MapleCCC
dece0b1fff assertRaises / assertRaisesRegex / assertWarns / assertWarnsRegex: msg argument is keyword-only (#8631) 2022-08-27 15:55:14 +01:00
Shane Harvey
7a73660f3f Fix hints for TestCase.assertRaises (#8373) 2022-07-23 10:43:38 +01:00
Alex Waygood
6348a58b8b Import Match and Pattern from re, not typing (#8277) 2022-07-12 15:32:48 +02:00
Alex Waygood
208d8e1ec2 Fix assertAlmostEqual regression on mixed numeric types (#8137) 2022-06-27 08:57:36 +02:00
Alex Waygood
8b3b6bf7cd stdlib: Audit Callable[<parameters>, None] annotations (#8187) 2022-06-27 08:08:28 +02:00
Alex Waygood
538621e91b unittest.case: tighter annotations for various assertions (#8077) 2022-06-20 18:49:57 +02:00
Alex Waygood
5add91d6bb unittest: Improve self.assert(Not)AlmostEqual(s) (#8066) 2022-06-14 18:24:51 +03:00
Alex Waygood
0ce825b5a8 Add unittest features new in Python 3.11 (#8020)
python/cpython@086c6b1
2022-06-04 16:27:52 +01:00
Alex Waygood
acc0167dc1 Fix several new-in-3.11 stubtest errors (#7973) 2022-06-02 18:07:38 -07:00
Alex Waygood
97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood
f4ae363b56 stdlib: correct many pos-or-kw arg names in dunder methods (#7451) 2022-03-07 16:40:03 +01:00
Alex Waygood
fbc279e3f5 stdlib: Add many missing dunder overrides (#7231) 2022-02-16 06:25:47 -08:00
Alex Waygood
1371a1e1fe unittest deprecations have been deferred until 3.12 (#7131)
See https://github.com/python/cpython/pull/30935
2022-02-04 15:52:30 -08:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Nikita Sobolev
20508d05f4 Use ParamSpec in unittest.case (#7012) 2022-01-25 10:25:28 +01:00
Alex Waygood
a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
Alex Waygood
8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Alex Waygood
975b3e901b Always alias collections.abc.Set (#6712) 2021-12-27 17:09:47 +01:00
Sebastian Rittau
3fb2bcd4c1 Restore stubtest 0.930 (#6663) 2021-12-22 20:18:19 -08:00
Sebastian Rittau
f6e3bd19f3 Fix unittest.case for Python < 3.9 (#6605)
_LoggingWatcher and _AssertLogsContext were moved to unittest._log in
Python 3.9, but were in unittest.case until 3.8.
2021-12-16 13:36:01 +01:00
Akuli
b3e8073bac Create unittest._log stub and improve _AssertLogsContext (#6428)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2021-11-30 21:39:14 -08:00
Alex Waygood
971908ca24 Add no_logs parameter to AssertLogsContext (#6426)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-28 15:25:43 +02:00
Alex Waygood
77725c5ed3 Add unittest.AssertNoLogs (#6414)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-28 12:30:19 +02:00
Akuli
a5bc1e037f Add mypy error codes to '# type: ignore' comments (#6379) 2021-11-26 07:07:56 +01:00
Alex Waygood
aa92ca9138 Revise unittest stub to reflect removed methods in 3.11 (#6373) 2021-11-24 09:43:03 -08:00
Alex Waygood
dc5f6410a8 DefaultDict -> defaultdict, typing.ContextManager -> contextlib.AbstractContextManager (#6351) 2021-11-21 07:07:35 -08:00
Alex Waygood
029cf555e7 Use lowercase set/deque in stdlib subdirectories (#6350) 2021-11-20 04:20:25 -08:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Anton Grübel
d68701c0ec Use _typeshed.Self with __enter__ (#5723)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-04 21:10:01 +03:00
Mark Vismonte
861f0a9844 Use collections.abc.Set in assertSetEqual (#5090) 2021-03-06 21:04:14 +01:00
Mark Vismonte
ea7f1f9c2d Use Mapping in assertDictEqual (#5088) 2021-03-04 15:52:21 -08:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00