summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix typos in the Lib directory (GH-28775)Christian Clauss2021-10-062-2/+2
| | | | | Fix typos in the Lib directory as identified by codespell. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449)Serhiy Storchaka2021-09-223-61/+174
| | | | | | It runs now asynchronous methods and callbacks. If it fails, doCleanups() can be called for cleaning up.
* bpo-30856: Update TestResult early, without buffering in _Outcome (GH-28180)Serhiy Storchaka2021-09-196-65/+70
| | | | | | | TestResult methods addFailure(), addError(), addSkip() and addSubTest() are now called immediately after raising an exception in test or finishing a subtest. Previously they were called only after finishing the test clean up.
* bpo-36674: Honour the skipping decorators in TestCase.debug() (GH-28446)Serhiy Storchaka2021-09-182-1/+75
| | | | | | | | unittest.TestCase.debug() raises now a SkipTest if the class or the test method are decorated with the skipping decorator. Previously it only raised a SkipTest if the test method was decorated with other decorator in addition to the skipping decorator, or if SkipTest was explicitly raised in the test or setup methods.
* bpo-45162: Remove many old deprecated unittest features (GH-28268)Serhiy Storchaka2021-09-1710-323/+25
| | | | | | | * "fail*" and "assert*" aliases of TestCase methods. * Broken from start TestCase method assertDictContainsSubset(). * Ignored TestLoader.loadTestsFromModule() parameter use_load_tests. * Old alias _TextTestResult of TextTestResult.
* bpo-5846: Fix deprecations for obsolete unittest functions and add tests. ↵Serhiy Storchaka2021-09-173-30/+69
| | | | (GH-28382)
* bpo-5846: Deprecate obsolete methods in `unittest` (GH-28299)Erlend Egeberg Aasland2021-09-151-2/+33
| | | Deprecate makeSuite, findTestCases, and getTestCaseNames. Scheduled for removal in Python 3.13.
* bpo-45156: Fixes inifite loop on unittest.mock.seal() (GH-28300)Nikita Sobolev2021-09-142-6/+68
| | | | | | Fixes infinite loop on unittest.mock.seal() of mocks created by unittest.create_autospec(). Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-5846: Do not use obsolete unittest functions. (GH-28303)Serhiy Storchaka2021-09-131-1/+1
| | | | Get rid of use of makeSuite() and findTestCases(). Also make test_math and test_threading_local discoverable.
* bpo-25894: Always report skipped and failed subtests separately (GH-28082)Serhiy Storchaka2021-09-102-49/+185
| | | | | | * In default mode output separate characters for skipped and failed subtests. * In verbose mode output separate lines (including description) for skipped and failed subtests. * In verbose mode output test description for errors in test cleanup.