Commit Graph

136 Commits

Author SHA1 Message Date
Semyon Moroz 0c0bad8831 [unittest] Improve annotations of three_way_cmp (#15003) 2025-11-14 17:02:11 +01:00
Semyon Moroz 0d100b9110 Make type of unitest.mock.Any a subclass of Any (#14708) 2025-09-14 20:25:41 +02:00
Jelle Zijlstra e8ba06f710 Add @disjoint_base decorator in the stdlib (#14599)
And fix some other new stubtest finds.
2025-08-24 07:27:14 -07:00
Sebastian Rittau f8773eb27a Improve unittest.mock stubs (#14421)
* Add `patch()` default arguments.
* Forbid certain argument combinations for `patch()`.
* Reorder `patch()` overloads.
* Add `unsafe` argument.
* Add overloads for `path.multiple()`.
2025-08-22 09:31:26 +02:00
Semyon Moroz 5e0d6ee95e [stdlib] Copy-edit deprecation messages (#14614)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-08-21 12:12:00 +01:00
Semyon Moroz 9bb8c4f1f9 [stdlib] Add missing Final (#14613) 2025-08-21 12:18:20 +02:00
Jelle Zijlstra 02a4b07b54 stdlib: add some parameter defaults (#14610) 2025-08-21 09:17:33 +02:00
Brian Schubert 622df68c1c Add @type_check_only to stub-only private classes in stdlib (#14512) 2025-08-03 10:13:16 +02:00
Sebastian Rittau 7e16c80989 Remove some pytype workarounds from stdlib (#14470)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-07-27 11:56:26 +01:00
Leonardus Chen a1ae191820 Fix unittest.mock.patch and unittest.mock.patch.object when new_callable is not None (#14358) 2025-07-16 14:37:32 +02:00
Semyon Moroz a92579c0b0 Bump unittest to 3.14 (#14012) 2025-05-11 14:40:17 +02:00
Noelle Leigh 1b267b25f2 stdlib/unittest/mock.pyi: Improve _Call types (#13845)
This fixes a number of issues related to `_Call` in `stdlib/unittest/mock.pyi`:

- `_Call.__new__()`, `_Call.__init__()`: The `parent` argument should be
  another `_Call` or `None`.
- `_Call.name` doesn't exist.
- `_Call.parent` doesn't exist.
- `_Call.from_kall` doesn't exist.
- [`NonCallableMock.call_args`][0] should be a `_Call` or `None`.

[0]: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args
2025-04-18 12:32:16 -07:00
Sebastian Rittau 30b16c168d Drop Python 3.8 branches (#13776) 2025-04-03 10:35:36 +02:00
Joren Hammudoglu ab46a26de8 Annotate unittest.TestCase.__init_subclass__ (#13602) 2025-03-09 13:47:43 +01:00
Stephen Morton 4c5f85be88 fixes for unittest.runner (#13205) 2024-12-27 20:09:30 -08:00
Stephen Morton 3944c7839e Add __hash__ for a bunch of types that set it to None (#13286) 2024-12-23 23:16:22 -08:00
Stephen Morton c64f9d065b unnecessary inheritance from ad-hoc protocol (#12882) 2024-10-23 07:11:51 -07:00
Jelle Zijlstra a2ee32ba5d unittest: make protocol parameter positional-only (#12834) 2024-10-17 16:55:50 +02:00
Stephen Morton a871efd90c remove unecessary Iterable base classes (#12810) 2024-10-15 00:53:35 +01:00
Stephen Morton 1a0b507ae7 add unittest.mock.Base to MagicMixin and MagicProxy (#12747)
This matches the runtime.
2024-10-06 13:17:42 -07:00
Avasam 98af3eb9da Add unittest.runner._WritelnDecorator (#12407) 2024-08-22 09:50:31 +02:00
sobolevn 6f248dfa37 Bump mypy to 1.11.1 (#12463) 2024-08-04 23:19:28 -07:00
Max Muoto b40eb642e0 Use Final for unittest constants (#12447) 2024-07-28 12:03:02 +02:00
Max Muoto 9bf9d1571e Fix unittest for 3.13 (#12307) 2024-07-10 10:23:58 +02:00
Shantanu d9cf43c4c3 Mark pos-only __class_getitem__ args (#11970) 2024-05-18 23:27:51 +02:00
Alex Waygood d0f2be92ab Bump pyright to v1.1.360 (#11810) 2024-04-24 14:09:16 +02:00
Shantanu 470a13ab09 Use PEP 570 syntax in stdlib (#11250) 2024-03-09 14:50:16 -08:00
Alex Waygood c49c84f319 A new shade of Black (#11362) 2024-02-04 16:38:55 -08:00
Sebastian Rittau 53a8193d64 Update typing_extensions imports in stdlib (#11244)
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2024-01-05 08:15:19 -08:00
Sebastian Rittau 23604858a6 Remove Python 3.7 branches (#11238) 2024-01-05 11:39:39 +01:00
Stephen Morton ad51dde631 add unittest.case._AssertRaisesBaseContext class (#11158) 2023-12-18 23:07:47 +01:00
Sebastian Rittau fdc195465b Add tests for TestCase.assertDictEqual() (#11154) 2023-12-12 16:41:18 +01:00
Alex Waygood 10febc4fe0 stdlib: remove unused type: ignore comments (#11061) 2023-11-23 14:00:07 +01:00
Alex Waygood 83964a4dc5 stdlib: add many missing __del__ methods (#11042) 2023-11-18 11:32:12 -08:00
Alex Waygood eebc28740e Revert "Use Callable[..., Any] instead of Callable[..., object] in unittest" (#8779) 2023-11-10 19:53:33 +01:00
Rob Percival cc0b41a994 Fix type hints for unittest.util.unorderable_list_difference() (#11012)
Fix type hints for unorderable_list_difference()

It claimed that the arguments were `Sequence` types (immutable), but the function removes elements from them, so they must be `MutableSequence` types. Specifically, it calls `pop()` on the first argument and `remove()` on the second argument.

See the function implementation for details:
https://github.com/python/cpython/blame/0b06d2482d77e02c5d40e221f6046c9c355458b2/Lib/unittest/util.py#L98-L113
2023-11-10 17:53:03 +00:00
Jelle Zijlstra 3229b36644 stdlib: More pos-only parameters to Protocols (#10987) 2023-11-06 23:45:12 +01:00
Imogen b76b2afdf3 Fix typings for unittest.TestCase.assertLessEqual (#10798) 2023-09-29 01:03:20 +02:00
Nikita Sobolev f0ba5ba2a2 Update unittest.mock to 3.12 (#10650)
And harmonise some annotations between the stdlib `unittest.mock` module and the third-party `mock` backport package.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-02 15:03:39 +01:00
Nikita Sobolev 6c2c164de2 unittest: py312 updates for load_tests and loadTestsFromModule (#10640) 2023-08-30 12:27:40 +01:00
Nikita Sobolev c9583d9f14 Add durations to unittest in 3.12 (#10636) 2023-08-30 11:35:25 +01:00
Nikita Sobolev 032f9195f9 Add a more precise signature for AsyncMock.reset_mock() (#10481) 2023-07-19 13:25:20 +01:00
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