summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-111019: Align expected and actual titles in test output ↵Miss Islington (bot)2023-10-181-3/+3
| | | | | | | | | | | (GH-111020) (#111024) gh-111019: Align expected and actual titles in test output (GH-111020) Align expected and actual titles in output from assert_has_calls/assert_called_with for greater readability (cherry picked from commit 77dbd956090aac66e264d9d640f6adb6b0930b87) Co-authored-by: James <morisja@gmail.com>
* [3.12] gh-106584: Fix exit code for unittest in Python 3.12 (GH-106588) ↵Miss Islington (bot)2023-10-022-5/+9
| | | | | | | | | | (#109725) gh-106584: Fix exit code for unittest in Python 3.12 (GH-106588) (cherry picked from commit 8fc071345b50dd3de61ebeeaa287ccef21d061b2) Co-authored-by: EliseevEgor <egor.eliseev@jetbrains.com> Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-84867: Do not load tests from TestCase and FunctionTestCase ↵Miss Islington (bot)2023-10-021-5/+17
| | | | | | | | (GH-100497) (#109327) gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497) (cherry picked from commit 66d1d7eb067d445f1ade151f4a6db3864dd9109f) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-104090: Fix unittest collectedDurations resources leak (GH-106795) ↵Miss Islington (bot)2023-07-191-1/+2
| | | | | | | | (#106888) gh-104090: Fix unittest collectedDurations resources leak (GH-106795) (cherry picked from commit 70b961ed93f67e34d0624e178f6029c886afaeee) Co-authored-by: Yonatan Bitton <bityob@gmail.com>
* gh-68968: Correcting message display issue with assertEqual (#103937)Michael Blahay2023-05-041-8/+23
|
* gh-62432: unittest runner: Exit code 5 if no tests were run (#102051)Stefano Rivera2023-04-272-1/+10
| | | | | | | | 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-161-1/+5
| | | | | address review comments to PR-12271 Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* gh-102978: Fix mock.patch function signatures for class and staticmethod ↵Tomas R2023-04-131-0/+6
| | | | | | | decorators (#103228) Fixes unittest.mock.patch not enforcing function signatures for methods decorated with @classmethod or @staticmethod when patch is called with autospec=True.
* bpo-4080: unittest durations (#12271)Giampaolo Rodola2023-04-024-6/+67
|
* Remove unused import of `warnings` from `unittest.loader` (#102479)JosephSBoyle2023-03-061-1/+0
|
* gh-96127: Fix `inspect.signature` call on mocks (#96335)Nikita Sobolev2023-01-071-1/+9
|
* gh-100690: [mock] hide `ATTRIB_DENY_LIST` and make it immutable (#100819)Nikita Sobolev2023-01-071-2/+6
|
* gh-100690: Raise an AttributeError when the assert_ prefix is forgotten when ↵Christian Klein2023-01-061-4/+10
| | | | | | | | using Mock (#100691) Mock objects which are not unsafe will now raise an AttributeError when accessing an attribute that matches the name of an assertion but without the prefix `assert_`, e.g. accessing `called_once` instead of `assert_called_once`. This is in addition to this already happening for accessing attributes with prefixes assert, assret, asert, aseert, and assrt.
* gh-100739: Respect mock spec when checking for unsafe prefixes (#100740)Christian Klein2023-01-041-1/+1
| | | Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-100287: Fix unittest.mock.seal with AsyncMock (#100496)Shantanu2022-12-241-4/+4
|
* gh-99482: remove `jython` compatibility parts from stdlib and tests (#99484)Nikita Sobolev2022-12-231-7/+5
|
* gh-83076: 3.8x speed improvement in (Async)Mock instantiation (#100252)Carl Meyer2022-12-231-16/+22
|
* gh-98458: unittest: bugfix for infinite loop while handling chained ↵AlexTate2022-12-041-1/+3
| | | | | | | exceptions that contain cycles (#98459) * Bugfix addressing infinite loop while handling self-referencing chained exception in TestResult._clean_tracebacks() * Bugfix extended to properly handle exception cycles in _clean_tracebacks. The "seen" set follows the approach used in the TracebackException class (thank you @iritkatriel for pointing it out) * adds a test for a single chained exception that holds a self-loop in its __cause__ and __context__ attributes
* gh-99645: Fix a bug in handling class cleanups in unittest.TestCase (GH-99646)Serhiy Storchaka2022-11-221-5/+5
| | | | | Now addClassCleanup() uses separate lists for different TestCase subclasses, and doClassCleanups() only cleans up the particular class.
* gh-98086: Now ``patch.dict`` can decorate async functions (#98095)Nikita Sobolev2022-11-111-0/+18
|
* gh-91803: Mock - fix error when using autospec methods with seal (#92213)andrei kulakov2022-11-071-0/+1
| | | | | | Fixes https://github.com/python/cpython/issues/91803. Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-98624 Add mutex to unittest.mock.NonCallableMock (#98688)noah-weingarden2022-10-281-28/+38
| | | | | | | | | | | * Added lock to NonCallableMock in unittest.mock * Add blurb * Nitpick blurb * Edit comment based on @Jason-Y-Z's review * Add link to GH issue
* gh-97837: Change deprecation warning message in `unittest` (#97838)Nikita Sobolev2022-10-052-2/+2
|
* gh-95736: Fix event loop creation in IsolatedAsyncioTestCase (GH-96033)Serhiy Storchaka2022-08-171-4/+4
| | | | | | It should be created before calling the setUp() method, but after checking for skipping a test. Automerge-Triggered-By: GH:tiran
* GH-95736: fix IsolatedAsyncioTestCase to initialize Runner before calling ↵Kumar Aditya2022-08-161-0/+4
| | | | setup functions (#95898)
* gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (#94050)Mehdi ABAAKOUK2022-06-301-0/+4
| | | | | | | | | The inspect version was not working with unittest.mock.AsyncMock. The fix introduces special-casing of AsyncMock in `inspect.iscoroutinefunction` equivalent to the one performed in `asyncio.iscoroutinefunction`. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Revert "bpo-45162: Revert "Remove many old deprecated unittest features"" ↵Serhiy Storchaka2022-06-264-85/+1
| | | | | | (GH-92556) This reverts commit b50322d20337ca468f2070eedb051a16ee1eba94.
* gh-93839: Move Lib/unttest/test/ to Lib/test/test_unittest/ (#94043)Victor Stinner2022-06-2131-18402/+0
| | | | | | | | * Move Lib/unittest/test/ to Lib/test/test_unittest/ * Remove Lib/test/test_unittest.py * Replace unittest.test with test.test_unittest * Remove unittest.load_tests() * Rewrite unittest __init__.py and __main__.py * Update build system, CODEOWNERS, and wasm_assets.py
* bpo-45046: Support context managers in unittest (GH-28045)Serhiy Storchaka2022-05-085-2/+218
| | | | | | Add methods enterContext() and enterClassContext() in TestCase. Add method enterAsyncContext() in IsolatedAsyncioTestCase. Add function enterModuleContext().
* gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)Victor Stinner2022-05-061-1/+3
| | | | | Fix tests failing with the PYTHONSAFEPATH=1 env var. Enhance also -P help in Python usage (python --help).
* Simplify testing the warning filename (GH-91868)Serhiy Storchaka2022-04-243-15/+15
| | | The context manager result has the "filename" attribute.
* bpo-14265: Adds fully qualified test name to unittest output (GH-32138)Sam Ezeh2022-03-292-35/+41
| | | Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-47062: Implement asyncio.Runner context manager (GH-31799)Andrew Svetlov2022-03-241-51/+19
| | | Co-authored-by: Zachary Ware <zach@python.org>
* bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)Christian Heimes2022-03-225-1/+12
| | | | | | | | | | | - Add requires_fork and requires_subprocess to more tests - Skip extension import tests if dlopen is not available - Don't assume that _testcapi is a shared extension - Skip a lot of socket tests that don't work on Emscripten - Skip mmap tests, mmap emulation is incomplete - venv does not work yet - Cannot get libc from executable The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
* bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654)Bader Zaidan2022-03-171-1/+1
|
* bpo-22859: deprecate unittest.main.TestProgram.usageExit (GH-30293)Carlos Damazio2022-03-171-0/+3
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API ↵Andrew Svetlov2022-03-142-38/+35
| | | | (GH-31837)
* bpo-24959: fix unittest.assertRaises bug where traceback entries are dropped ↵Irit Katriel2022-03-082-14/+94
| | | | from chained exceptions (GH-23688)
* bpo-46877: export unittest.doModuleCleanups in unittest package (#31613)Kumar Aditya2022-03-031-2/+2
|
* bpo-46852: Remove the float.__set_format__() method (GH-31585)Victor Stinner2022-02-251-1/+1
| | | | | | Remove the undocumented private float.__set_format__() method, previously known as float.__set_format__() in Python 3.7. Its docstring said: "You probably don't want to use this function. It exists mainly to be used in Python's test suite."
* bpo-46709: check eval breaker in specialized `CALL` opcodes (GH-31404)Nikita Sobolev2022-02-181-59/+85
|
* Restrict use of Mock objects as specs (GH-31090)Matthew Suozzo2022-02-033-3/+19
| | | | | Follow-on to https://github.com/python/cpython/pull/25326 This covers cases where mock objects are passed directly to spec.
* bpo-45162: Revert "Remove many old deprecated unittest features" (GH-30935)Gregory P. Smith2022-01-2710-25/+323
| | | | | | | | | | Revert "bpo-45162: Remove many old deprecated unittest features (GH-28268)" This reverts commit b0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b. We're deferring this change until 3.12 while upstream projects that use the legacy assertion method names are fixed. See the issue for links to the discussion. Many upstream projects now have issues and PRs filed.
* bpo-41403: Improve error message for invalid mock target (GH-30833)Irit Katriel2022-01-232-5/+10
|
* bpo-46425: Fix direct invocation of multiple test modules (GH-30666)Nikita Sobolev2022-01-181-1/+1
|
* bpo-23882: unittest: Drop PEP 420 support from discovery. (GH-29745)Inada Naoki2022-01-102-76/+15
|
* bpo-22815: Print unexpected successes in summary in TextTestResult (GH-30138)Serhiy Storchaka2021-12-262-8/+38
|
* bpo-46129: Rewrite asyncio.locks tests with IsolatedAsyncioTestCase (GH-30198)Andrew Svetlov2021-12-191-1/+0
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* bpo-46111: Fix unittest tests in optimized mode (GH-30163)Serhiy Storchaka2021-12-173-3/+6
|
* bpo-13236: Flush the output stream more often in unittest (GH-29864)Serhiy Storchaka2021-12-043-5/+52
| | | It can prevent some losses when output to buffered stream.