aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_unittest
Commit message (Collapse)AuthorAge
* gh-127949: deprecate `asyncio.set_event_loop` (#128218)Kumar Aditya2024-12-24
| | | Deprecate `asyncio.set_event_loop` to be removed in Python 3.16.
* gh-127949: deprecate `asyncio.get_event_loop_policy` (#128053)Kumar Aditya2024-12-18
| | | This deprecates `asyncio.get_event_loop_policy` and will be removed in Python 3.16.
* gh-127949: deprecate `asyncio.set_event_loop_policy` (#128024)Kumar Aditya2024-12-18
| | | | First step towards deprecating the asyncio policy system. This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
* gh-127221: Add colour to unittest output (#127223)Hugo van Kemenade2024-12-05
| | | Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-104745: Limit starting a patcher more than once without stopping it (#126649)Red4Ru2024-11-13
| | | | | | | | Previously, this would cause an `AttributeError` if the patch stopped more than once after this, and would also disrupt the original patched object. --------- Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-80958: unittest: discovery support for namespace packages as start ↵Jacob Walls2024-10-23
| | | | directory (#123820)
* gh-125522 : add explicit exception types to bare excepts in tests (#125523)Irit Katriel2024-10-15
|
* gh-124176: Add special support for dataclasses to `create_autospec` (#124429)sobolevn2024-09-27
|
* gh-123934: Fix `MagicMock` not to reset magic method return values (#124038)sobolevn2024-09-19
|
* gh-123087: ``Lib/test/test_unittest/testmock/testasync.py``: Replace usage ↵Kirill Podoprigora2024-08-17
| | | | | of the deprecated ``asyncio.iscoroutinefunction`` with the ``inspect.iscoroutinefunction`` (#123088) asyncio.iscoroutinefunction -> inspect.iscoroutinefunction
* gh-122858: Deprecate `asyncio.iscoroutinefunction` (#122875)Wulian2024-08-11
| | | | | Deprecate `asyncio.iscoroutinefunction` in favor of `inspect.iscoroutinefunction`. Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-121708: Improve test coverage for `unittest.util` (GH-121713)Tomas R2024-07-14
|
* gh-120732: Fix `name` passing to `Mock`, when using kwargs to ↵Nikita Sobolev2024-06-19
| | | | `create_autospec` (#120737)
* gh-120544: Add `else: fail()` to tests where exception is expected (#120545)Nikita Sobolev2024-06-15
|
* gh-120388: Improve deprecation warning message, when test returns non-None ↵Nikita Sobolev2024-06-12
| | | | | | (#120401) Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-65454: avoid triggering call to a PropertyMock in ↵blhsing2024-06-11
| | | | NonCallableMock.__setattr__ (#120019)
* gh-119600: mock: do not access attributes of original when new_callable is ↵Robert Collins2024-06-11
| | | | | | | | | | set (#119601) In order to patch flask.g e.g. as in #84982, that proxies getattr must not be invoked. For that, mock must not try to read from the original object. In some cases that is unavoidable, e.g. when doing autospec. However, patch("flask.g", new_callable=MagicMock) should be entirely safe.
* gh-90848: Fixed create_autospec ignoring configure_mock style kwargs (#118163)infohash2024-05-02
|
* gh-117860: Add tests for resolving names when import rebind names (GH-118176)Serhiy Storchaka2024-04-30
| | | | | | Add tests for "import", pkgutil.resolve_name() and unittest.mock.path() for cases when "import a.b as x" and "from a import b as x" give different results.
* gh-59215: unittest: restore _top_level_dir at end of discovery (GH-15242)Zackery Spytz2024-04-03
|
* GH-70647: Deprecate strptime day of month parsing without a year present to ↵Gregory P. Smith2024-04-03
| | | | avoid leap-year bugs (GH-117107)
* gh-75988: Fix issues with autospec ignoring wrapped object (#115223)infohash2024-03-08
| | | | | | | | | | | * set default return value of functional types as _mock_return_value * added test of wrapping child attributes * added backward compatibility with explicit return * added docs on the order of precedence * added test to check default return_value
* gh-115274: Fix direct invocation of `testmock/testpatch.py` (#115275)Nikita Sobolev2024-02-11
|
* gh-113267: Revert "gh-106584: Fix exit code for unittest in Python 3.12 ↵Serhiy Storchaka2024-02-04
| | | | | | (#106588)" (GH-114470) This reverts commit 8fc071345b50dd3de61ebeeaa287ccef21d061b2.
* GH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths ↵Barney Gale2024-01-13
| | | | | | | | | | | | | (#113829) On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
* GH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)Stefano Rivera2024-01-09
| | | | | The intention of exiting 5 was to detect issues where the test suite wasn't discovered at all. If we skipped tests, it was correctly discovered.
* gh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573)wookie1842024-01-04
|
* gh-110774: allow setting the Runner(loop_factory=...) from ↵Thomas Grainger2023-10-31
| | | | | | | IsolatedAsyncioTestCase (#110776) Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
* gh-111019: Align expected and actual titles in test output (#111020)James2023-10-18
| | | | Align expected and actual titles in output from assert_has_calls/assert_called_with for greater readability
* gh-109653: Remove unused imports in the `Lib/` directory (#109803)Alex Waygood2023-09-24
|
* gh-106584: Fix exit code for unittest in Python 3.12 (#106588)EliseevEgor2023-09-22
| | | | | Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497)Nikita Sobolev2023-09-12
|
* gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929)Nikita Sobolev2023-09-05
|
* Update Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimError to ↵Sangyun_LEE2023-09-03
| | | | RuntimeError (#108847)
* gh-106300: Improve errors testing in test_unittest.test_runner (GH-106737)Nikita Sobolev2023-08-16
| | | Use a custom exception to prevent unintentional silence of actual errors.
* gh-61215: threadingmock: Improve test suite to avoid race conditions (#106822)Mario Corchero2023-07-17
| | | | | | | | threadingmock: Improve test suite to avoid race conditions Simplify tests and split them into multiple tests to prevent assertions from triggering race conditions. Additionally, we rely on calling the mocks without delay to validate the functionality of matching calls.
* Remove unused branches from mock module (#106617)Chris Withers2023-07-11
| | | | | | | * lambda has a name of __none__, but no async lambda so this branch is not needed * _get_signature_object only returns None for bound builtins. There are no async builtins so this branch isn't needed * Exclude a couple of methods from coverage checking in the downstream rolling backport of mock
* gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302)Nikita Sobolev2023-07-07
|
* gh-106458: Mark `testthreadingmock.py` with `@requires_working_threading` ↵Mario Corchero2023-07-06
| | | | | | | (GH-106366) Mark `testthreadingmock.py` with `threading_helper.requires_working_threading`. Also add longer delays to reduce the change of a race conditions on the tests that validate short timeouts.
* gh-61215: Rename `wait_until_any_call` to `wait_until_any_call_with` (#106414)Mario Corchero2023-07-04
| | | | | | mock: Rename `wait_until_any_call` to `wait_until_any_call_with` Rename the method to be more explicit that it expects the args and kwargs to wait for.
* gh-61215: New mock to wait for multi-threaded events to happen (#16094)Mario Corchero2023-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mock: Add `ThreadingMock` class Add a new class that allows to wait for a call to happen by using `Event` objects. This mock class can be used to test and validate expectations of multithreading code. It uses two attributes for events to distinguish calls with any argument and calls with specific arguments. The calls with specific arguments need a lock to prevent two calls in parallel from creating the same event twice. The timeout is configured at class and constructor level to allow users to set a timeout, we considered passing it as an argument to the function but it could collide with a function parameter. Alternatively we also considered passing it as positional only but from an API caller perspective it was unclear what the first number meant on the function call, think `mock.wait_until_called(1, "arg1", "arg2")`, where 1 is the timeout. Lastly we also considered adding the new attributes to magic mock directly rather than having a custom mock class for multi threading scenarios, but we preferred to have specialised class that can be composed if necessary. Additionally, having added it to `MagicMock` directly would have resulted in `AsyncMock` having this logic, which would not work as expected, since when if user "waits" on a coroutine does not have the same meaning as waiting on a standard call. Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
* bpo-44185: Added close() to mock_open __exit__ (#26902)Samet YASLAN2023-06-11
|
* gh-94924: support `inspect.iscoroutinefunction` in ↵Thomas Grainger2023-06-09
| | | | | | | | | | `create_autospec(async_def)` (#94962) * support inspect.iscoroutinefunction in create_autospec(async_def) * test create_autospec with inspect.iscoroutine and inspect.iscoroutinefunction * test when create_autospec functions check their signature
* gh-105407: Remove unused imports in tests (#105408)Victor Stinner2023-06-06
|
* gh-83403: Test `parent` param in `Mock.__init__` (#103630)Nikita Sobolev2023-05-30
|
* gh-104835: Remove unittest's deprecated getTestCaseNames, makeSuite, ↵Hugo van Kemenade2023-05-24
| | | | findTestCases (#104836)
* gh-85934: Use getattr_static when adding mock spec (#22209)melanie witt2023-05-23
| | | | Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-68968: Correcting message display issue with assertEqual (#103937)Michael Blahay2023-05-04
|
* gh-62432: unittest runner: Exit code 5 if no tests were run (#102051)Stefano Rivera2023-04-27
| | | | | | | | As discussed in https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498/7 It is common for test runner misconfiguration to fail to find any tests, This should be an error. Fixes: #62432
* gh-48330: address review comments to PR-12271 (#103209)Giampaolo Rodola2023-04-17
| | | | | address review comments to PR-12271 Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>