Commit Graph

94 Commits

Author SHA1 Message Date
Alex Waygood
03b4bb9cce Stdlib: add many missing __hash__ and __eq__ methods (#10464) 2023-07-17 14:21:02 +02:00
Sebastian Rittau
7ea173c4ad Fix @patch when new is missing (#10459) 2023-07-14 12:53:13 +02:00
Shantanu
9e86c6026a unittest.mock: use ParamSpec in patch (#10325)
Fixes #10324
2023-06-20 13:48:49 +02:00
Lucina
41b8981368 unittest.mock.__version__ was removed in 3.9 (#10056)
See the first entry in https://docs.python.org/3/whatsnew/3.9.html#removed
2023-04-17 11:51:34 -06:00
Alex Waygood
dd2818a41d Stdlib: add container default values (#9909) 2023-03-21 09:12:34 +01:00
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
Avasam
140bba3425 Add comments when subclassing Any (#9732) 2023-02-14 14:11:56 +01:00
Avasam
a768744d51 Type and mark as final module-level dunders not meant to be overwritten in stdlib/ (#9709) 2023-02-12 16:15:20 +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
Alex Waygood
352f496d69 Unpin stubtest from Python 3.10.8 and 3.11.0 (#9368) 2022-12-20 20:31:13 +00: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
Nikita Sobolev
18e2ae762b Mark first argument of __[get|set|del]attr__ as str (#9245) 2022-11-22 11:06:50 +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
Sebastian Rittau
e7e94dd101 Make unittest.patch.* methods static (#7543) 2022-11-01 13:09:56 +01:00
Nikita Sobolev
380022c650 Remove empty __init__ methods (#8816) 2022-09-30 13:08:41 +01:00
Shane Harvey
1a2914adc5 Use Callable[..., Any] instead of Callable[..., object] in unittest (#8399) 2022-09-21 13:46:38 +01:00
Pierre Riandey
70d76ecf8f Add types for unittest.loader.TestLoader._match_path (#8669) 2022-09-02 09:55:24 +02:00
MapleCCC
dece0b1fff assertRaises / assertRaisesRegex / assertWarns / assertWarnsRegex: msg argument is keyword-only (#8631) 2022-08-27 15:55:14 +01:00
Nikita Sobolev
0259068ad6 Remove duplicate definitions in sub-classes (#8594) 2022-08-26 17:10:55 +02:00
Nikita Sobolev
0480550fc3 Adds missing __dir__ definitions (#8479) 2022-08-04 12:21:43 +02:00
Shane Harvey
7a73660f3f Fix hints for TestCase.assertRaises (#8373) 2022-07-23 10:43:38 +01:00
Alex Waygood
35616b439f Run pycln as a pre-commit hook in CI (#8304) 2022-07-18 09:27:28 +02:00
Alex Waygood
6348a58b8b Import Match and Pattern from re, not typing (#8277) 2022-07-12 15:32:48 +02:00
Alex Waygood
edc0ecd857 Remove Python 3.6 branches from typeshed (#8269) 2022-07-11 10:55:17 +02:00
Alex Waygood
fffb25201a Delete some works of fiction (#8247) 2022-07-06 22:49:18 +05:30
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
b88ea4a499 Simplify __all__ for unittest and xml.etree (#8029) 2022-06-07 12:03:52 -07:00
Alex Waygood
43a9ab08d7 Always use TypeAlias when assigning to Any (#8021) 2022-06-05 18:16:20 -07: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
Jelle Zijlstra
66383ee8e3 unittest.mock: target must be a str (#7672)
See [the CPython source](eaa85cb22f/Lib/unittest/mock.py (L1754)). It calls `_get_target`, and [that](eaa85cb22f/Lib/unittest/mock.py (L1594)) does `target.rsplit('.', 1)`.
2022-04-21 14:07:55 -07:00
Alex Waygood
a8504f269e Use _typeshed.OptExcInfo in pydoc and unittest (#7668) 2022-04-20 21:00:48 +01:00
Alex Waygood
b093c90a94 Use TypeAlias for type aliases where possible, part II (#7667) 2022-04-20 20:02:47 +01:00
Alex Waygood
97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood
da3e69d093 stdlib: Improve a bunch of __(a)exit__ methods (#7571) 2022-04-01 08:05:25 +02:00
Alex Waygood
1245bbcc8d Use type alias to simplify overloads in unittest.mock (#7563) 2022-03-29 08:19:26 +02:00
Alex Waygood
340c6c97ed Add mypy error codes to type: ignores, remove unused ignores (#7504)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-19 13:10:00 +00:00
Alex Waygood
3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Alex Waygood
f4ae363b56 stdlib: correct many pos-or-kw arg names in dunder methods (#7451) 2022-03-07 16:40:03 +01:00
Itai Steinherz
b9909b121e Add missing typings to unittest.mock (#7431) 2022-03-06 15:43:39 -08:00
Alex Waygood
58e505eeb2 Add __all__ for modules beginning with 'u', 'x', 'w' and 'z' (#7374) 2022-02-23 23:04:21 +01:00