Hugo van Kemenade
b1cb30ec86
gh-104835: Remove unittest's deprecated getTestCaseNames, makeSuite, findTestCases ( #104836 )
2023-05-24 21:16:43 +00:00
melanie witt
2e0931046d
gh-85934: Use getattr_static when adding mock spec ( #22209 )
...
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-23 17:10:34 -06:00
Michael Blahay
46361bb843
gh-68968: Correcting message display issue with assertEqual ( #103937 )
2023-05-04 16:37:17 -06:00
Stefano Rivera
76632b836c
gh-62432: unittest runner: Exit code 5 if no tests were run ( #102051 )
...
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
2023-04-27 01:28:46 +00:00
Giampaolo Rodola
ff3303e49c
gh-48330: address review comments to PR-12271 ( #103209 )
...
address review comments to PR-12271
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
2023-04-17 00:19:44 +02:00
Tomas R
59e0de4903
gh-102978: Fix mock.patch function signatures for class and staticmethod decorators ( #103228 )
...
Fixes unittest.mock.patch not enforcing function signatures for methods
decorated with @classmethod or @staticmethod when patch is called with
autospec=True.
2023-04-13 08:37:57 +01:00
Giampaolo Rodola
6883007a86
bpo-4080: unittest durations ( #12271 )
2023-04-03 00:12:51 +02:00
JosephSBoyle
c84e6f32df
Remove unused import of `warnings` from `unittest.loader` ( #102479 )
2023-03-06 22:02:19 +00:00
Nikita Sobolev
9e7d7266ec
gh-96127: Fix `inspect.signature` call on mocks ( #96335 )
2023-01-07 10:49:15 +00:00
Nikita Sobolev
a109454e82
gh-100690: [mock] hide `ATTRIB_DENY_LIST` and make it immutable ( #100819 )
2023-01-07 10:25:05 +00:00
Christian Klein
1d4d677d1c
gh-100690: Raise an AttributeError when the assert_ prefix is forgotten when 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.
2023-01-06 18:38:50 +00:00
Christian Klein
7f1eefc6f4
gh-100739: Respect mock spec when checking for unsafe prefixes ( #100740 )
...
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-01-04 22:31:29 +00:00
Shantanu
e4b43ebb3a
gh-100287: Fix unittest.mock.seal with AsyncMock ( #100496 )
2022-12-24 19:39:39 +00:00
Nikita Sobolev
745545b5bb
gh-99482: remove `jython` compatibility parts from stdlib and tests ( #99484 )
2022-12-23 14:17:24 -06:00
Carl Meyer
c5726b727e
gh-83076: 3.8x speed improvement in (Async)Mock instantiation ( #100252 )
2022-12-23 19:41:37 +00:00
AlexTate
72ec518203
gh-98458: unittest: bugfix for infinite loop while handling chained 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
2022-12-04 11:37:55 -08:00
Serhiy Storchaka
c2102136be
gh-99645: Fix a bug in handling class cleanups in unittest.TestCase (GH-99646)
...
Now addClassCleanup() uses separate lists for different TestCase subclasses,
and doClassCleanups() only cleans up the particular class.
2022-11-22 17:49:37 +02:00
Nikita Sobolev
67b4d2772c
gh-98086: Now ``patch.dict`` can decorate async functions ( #98095 )
2022-11-11 08:04:30 +00:00
andrei kulakov
c6325b1c9f
gh-91803: Mock - fix error when using autospec methods with seal ( #92213 )
...
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>
2022-11-07 07:24:46 +00:00
noah-weingarden
0346eddbe9
gh-98624 Add mutex to unittest.mock.NonCallableMock ( #98688 )
...
* 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
2022-10-28 08:51:18 +01:00
Nikita Sobolev
c3648f4e4a
gh-97837: Change deprecation warning message in `unittest` ( #97838 )
2022-10-04 17:29:18 -07:00
Serhiy Storchaka
36517101dd
gh-95736: Fix event loop creation in IsolatedAsyncioTestCase (GH-96033)
...
It should be created before calling the setUp() method, but after
checking for skipping a test.
Automerge-Triggered-By: GH:tiran
2022-08-17 02:05:17 -07:00
Kumar Aditya
9d515997f9
GH-95736: fix IsolatedAsyncioTestCase to initialize Runner before calling setup functions ( #95898 )
2022-08-16 08:52:06 -07:00
Mehdi ABAAKOUK
4261b6bffc
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock ( #94050 )
...
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>
2022-06-30 19:08:38 +02:00
Serhiy Storchaka
c834c02569
Revert "bpo-45162: Revert "Remove many old deprecated unittest features"" (GH-92556)
...
This reverts commit b50322d203
.
2022-06-26 10:18:06 +03:00
Victor Stinner
c735d54534
gh-93839: Move Lib/unttest/test/ to Lib/test/test_unittest/ ( #94043 )
...
* 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
2022-06-21 10:27:59 +02:00
Serhiy Storchaka
086c6b1b0f
bpo-45046: Support context managers in unittest (GH-28045)
...
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
2022-05-08 17:49:09 +03:00
Victor Stinner
329afe78c3
gh-57684: Update tests for PYTHONSAFEPATH=1 ( #92358 )
...
Fix tests failing with the PYTHONSAFEPATH=1 env var.
Enhance also -P help in Python usage (python --help).
2022-05-06 03:41:24 +02:00
Serhiy Storchaka
090721721b
Simplify testing the warning filename (GH-91868)
...
The context manager result has the "filename" attribute.
2022-04-24 10:23:59 +03:00
Sam Ezeh
755be9b150
bpo-14265: Adds fully qualified test name to unittest output (GH-32138)
...
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-29 18:02:09 +03:00
Andrew Svetlov
4119d2d7c9
bpo-47062: Implement asyncio.Runner context manager (GH-31799)
...
Co-authored-by: Zachary Ware <zach@python.org>
2022-03-24 21:51:16 +02:00
Christian Heimes
deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
...
- 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).
2022-03-22 03:04:36 -07:00
Bader Zaidan
a0db11b10f
bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654)
2022-03-17 16:37:52 -07:00
Carlos Damazio
7c353b7594
bpo-22859: deprecate unittest.main.TestProgram.usageExit (GH-30293)
...
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-16 19:41:02 -07:00
Andrew Svetlov
9523c0d84f
bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API (GH-31837)
2022-03-14 13:54:13 +02:00
Irit Katriel
88b7d86a73
bpo-24959: fix unittest.assertRaises bug where traceback entries are dropped from chained exceptions (GH-23688)
2022-03-08 21:43:49 +00:00
Kumar Aditya
cc400585fa
bpo-46877: export unittest.doModuleCleanups in unittest package ( #31613 )
2022-03-03 10:41:28 -08:00
Victor Stinner
5ab745fc51
bpo-46852: Remove the float.__set_format__() method (GH-31585)
...
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."
2022-02-26 00:53:27 +01:00
Nikita Sobolev
e2c28616ce
bpo-46709: check eval breaker in specialized `CALL` opcodes (GH-31404)
2022-02-18 12:56:23 +00:00
Matthew Suozzo
6394e981ad
Restrict use of Mock objects as specs (GH-31090)
...
Follow-on to https://github.com/python/cpython/pull/25326
This covers cases where mock objects are passed directly to spec.
2022-02-03 00:41:19 -08:00
Gregory P. Smith
b50322d203
bpo-45162: Revert "Remove many old deprecated unittest features" (GH-30935)
...
Revert "bpo-45162: Remove many old deprecated unittest features (GH-28268)"
This reverts commit b0a6ede3d0
.
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.
2022-01-26 20:39:15 -08:00
Irit Katriel
f7955a82e3
bpo-41403: Improve error message for invalid mock target (GH-30833)
2022-01-23 18:42:41 +00:00
Nikita Sobolev
1292aa6db5
bpo-46425: Fix direct invocation of multiple test modules (GH-30666)
2022-01-18 21:28:18 +02:00
Inada Naoki
0b2b9d2513
bpo-23882: unittest: Drop PEP 420 support from discovery. (GH-29745)
2022-01-10 10:38:33 +09:00
Serhiy Storchaka
1944434b44
bpo-22815: Print unexpected successes in summary in TextTestResult (GH-30138)
2021-12-26 13:22:44 +02:00
Andrew Svetlov
9c06fd8951
bpo-46129: Rewrite asyncio.locks tests with IsolatedAsyncioTestCase (GH-30198)
...
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2021-12-19 16:35:56 +02:00
Serhiy Storchaka
95a922b3bb
bpo-46111: Fix unittest tests in optimized mode (GH-30163)
2021-12-17 11:10:55 +02:00
Serhiy Storchaka
f42a06ba27
bpo-13236: Flush the output stream more often in unittest (GH-29864)
...
It can prevent some losses when output to buffered stream.
2021-12-04 20:57:20 +02:00
Christian Clauss
745c9d9dfc
Fix typos in the Lib directory (GH-28775)
...
Fix typos in the Lib directory as identified by codespell.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-10-06 16:13:48 -07:00
Serhiy Storchaka
ecb6922ff2
bpo-45238: Fix unittest.IsolatedAsyncioTestCase.debug() (GH-28449)
...
It runs now asynchronous methods and callbacks.
If it fails, doCleanups() can be called for cleaning up.
2021-09-22 17:43:23 +02:00