| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
(cherry picked from commit 7f1eefc6f4843f0fca60308f557a71af11d18a53)
Co-authored-by: Christian Klein <167265+cklein@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
| |
(cherry picked from commit e4b43ebb3afbd231a4e5630e7e358aa3093f8677)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
|
| |
exceptions that contain cycles (GH-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
(cherry picked from commit 72ec518203c3f3577a5e888b12f10bb49060e6c2)
Co-authored-by: AlexTate <0xalextate@gmail.com>
|
|
|
|
|
|
|
|
|
| |
(GH-99646) (GH-99699)
Now addClassCleanup() uses separate lists for different TestCase subclasses,
and doClassCleanups() only cleans up the particular class.
(cherry picked from commit c2102136be569e6fc8ed90181f229b46d07142f8)
|
|
|
|
| |
(cherry picked from commit 653e563d80fabee8830e0b55f194f82a9beabe70)
|
|
|
|
|
|
|
|
|
| |
(GH-99366)
gh-98086: Now ``patch.dict`` can decorate async functions (GH-98095)
(cherry picked from commit 67b4d2772c5124b908f8ed9b13166a79bbeb88d2)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Chris Withers <chris@withers.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-96135) (GH-96235)
Tests for IsolatedAsyncioTestCase.debug() rely on the runner be closed
in __del__. It makes tests depending on the GC an unreliable on other
implementations. It is better to tear down the loop explicitly even if
currently there is no a public API for this.
(cherry picked from commit 4de06e3cc0a58d73934f9a2759ad9cd2f6b031b0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
| |
from chained exceptions (GH-23688)
(cherry picked from commit 88b7d86a73da9388aa65c96401c2984c8c16f8db)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
|
|
|
| |
(cherry picked from commit f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418)
|
|
|
|
| |
(GH-30699)
|
|
|
|
|
| |
(cherry picked from commit 95a922b3bb3af247ec141d73fcdfbf68bb1d32a5)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-29929)
It can prevent some losses when output to buffered stream..
(cherry picked from commit f42a06ba279c916fb67289e47f9bc60dc5dee4ee)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
| |
test code (#26497)
|
|
|
|
|
|
|
|
| |
Fix typos in the Lib directory as identified by codespell.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>.
(cherry picked from commit 745c9d9dfc1ad6fdfdf1d07420c6273ff67fa5be)
Co-authored-by: Christian Clauss <cclauss@me.com>
|
|
|
|
|
|
|
|
|
|
| |
(GH-28521)
It runs now asynchronous methods and callbacks.
If it fails, doCleanups() can be called for cleaning up.
(cherry picked from commit ecb6922ff2d56476a6cfb0941ae55aca5e7fae3d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
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.
(cherry picked from commit dea59cf88adf5d20812edda330e085a4695baba4)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Fixes infinite loop on unittest.mock.seal() of mocks created by
unittest.create_autospec().
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
(cherry picked from commit 7f60c9e1c6e22cc0e846a872c318570926cd3094)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
| |
(GH-28005) (GH-28027)
(cherry picked from commit 2a8127cafe1d196f858a3ecabf5f1df3eebf9a12)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 28264269de9ff88d9ee7110fc56ac2d2db275bec)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Functions registered with addModuleCleanup() were not called unless
the user defines tearDownModule() in their test module.
* Functions registered with addClassCleanup() were not called if
tearDownClass is set to None.
* Buffering in TestResult did not work with functions registered
with addClassCleanup() and addModuleCleanup().
* Errors in functions registered with addClassCleanup() and
addModuleCleanup() were not handled correctly in buffered and
debug modes.
* Errors in setUpModule() and functions registered with
addModuleCleanup() were reported in wrong order.
* And several lesser bugs.
(cherry picked from commit 08d9e597c8ef5a2b26375ac954fdf224f5d82c3c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Previously it returned None if the test class or method was
decorated with a skipping decorator.
Co-authored-by: Iman Tabrizian <iman.tabrizian@gmail.com>
(cherry picked from commit 7e246a3a7b43762480ee4fe0cfb859e8e997a8c8)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
objects (GH-27831)
Method stopTestRun() is now always called in pair with method startTestRun()
for TestResult objects implicitly created in TestCase.run().
Previously it was not called for test methods and classes decorated with
a skipping decorator.
(cherry picked from commit a9640d75531d6cbbfd254b65435f238c26bf5cd9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
| |
leaked tasks (GH-27765)
(cherry picked from commit 2cb1a6806c0cefab0c3a40fdd428a89a4392570e)
Co-authored-by: Bar Harel <bar.harel@biocatch.com>
|
|
|
|
| |
* Restrict using Mock objects as specs as this is always a test bug where the resulting mock is misleadingly useless.
* Skip a broken test that exposes a bug elsewhere in mock (noted in the original issue).
|
|
|
|
|
|
|
|
|
|
|
|
| |
patch, patch.object and create_autospec silently ignore misspelled
arguments such as autospect, auto_spec and set_spec. This can lead
to tests failing to check what they are supposed to check.
This change adds a check causing a RuntimeError if the above
functions get any of the above misspellings as arguments. It also
adds a new argument, "unsafe", which can be set to True to disable
this check.
Also add "!r" to format specifiers in added error messages.
|
|
|
|
|
|
|
|
|
| |
This is a follow-up to
https://github.com/python/cpython/commit/4662fa9bfe4a849fe87bfb321d8ef0956c89a772.
That original commit expanded guards against misspelling assertions on
mocks. This follow-up updates the documentation and improves the error
message by pointing out the potential cause and solution.
Automerge-Triggered-By: GH:gpshead
|
|
|
|
|
|
| |
its __bool__ function (GH23613)
Check if NonCallableMock's spec_arg is not None instead of call its __bool__ function
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, a Mock object which is not unsafe will raise an
AttributeError if an attribute with the prefix assert or assret is
accessed on it. This protects against misspellings of real assert
method calls, which lead to tests passing silently even if the tested
code does not satisfy the intended assertion.
Recently a check was done in a large code base (Google) and three
more frequent ways of misspelling assert were found causing harm:
asert, aseert, assrt. These are now added to the existing check.
|
|
|
|
|
|
|
|
|
| |
(GH-22565)
… by level
@vsajip , @pitrou
Automerge-Triggered-By: GH:vsajip
|
| |
|
| |
|
|
|
| |
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
|
|
|
|
|
|
|
| |
unittest.TestCase.assertWarns no longer raises a RuntimeException
when accessing a module's ``__warningregistry__`` causes importation of a new
module, or when a new module is imported in another thread.
Patch by Kernc.
|
|
|
| |
Automerge-Triggered-By: @vstinner
|
|
|
|
|
|
|
| |
methods in MagicMock" (GH-19734)
* Revert "bpo-25597: Ensure wraps' return value is used for magic methods in MagicMock (#16029)"
This reverts commit 72b1004657e60c900e4cd031b2635b587f4b280e.
|
|
|
|
|
| |
Patcher's __exit__() is now never called if its __enter__() is failed.
Returning true from __exit__() silences now the exception.
|
|
|
|
|
| |
coroutines were awaited (GH-18924)
Create call objects with awaited arguments instead of using call_args which has only last call value.
|
|
|
|
| |
TestCase.shortDescription (GH-18175)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* use the `: pass` and `: yield` patterns for code that isn't expected to ever be executed.
* The _Call items passed to _AnyComparer are only ever of length two, so assert instead of if/else
* fix typo
* Fix bug, where stop-without-start patching dict blows up with `TypeError: 'NoneType' object is not iterable`, highlighted by lack of coverage of an except branch.
* The fix for bpo-37972 means _Call.count and _Call.index are no longer needed.
* add coverage for calling next() on a mock_open with readline.return_value set.
* __aiter__ is defined on the Mock so the one on _AsyncIterator is never called.
|
|
|
|
|
| |
- The gc.collect is needed for other implementations, such as pypy
- Using context managers over multiple lines will only catch the warning from the first line in the context!
- remove a skip for a test that no longer fails on pypy
|
|
|
|
|
|
|
|
| |
* asyncio.run only available in 3.8+
* iscoroutinefunction has important bungfixes in 3.8
* IsolatedAsyncioTestCase only available in 3.8+
|
|
|
|
| |
(#16029)
|
| |
|
| |
|
|
|
|
| |
(GH-16784)
|
|
|
|
|
| |
As the function was not registering in the active patches, the mocks
started by `mock.patch.dict` were not being stopped when
`mock.patch.stopall` was being called.
|
|
|
|
|
| |
* add test for path.dict using OrderedDict
Co-authored-by: Yu Tomita nekobon@users.noreply.github.com
|
|
|
|
|
| |
* Add test for nested async decorator patch.
* Add test for side_effect and wraps with a function.
* Add test for side_effect with an exception in the iterable.
|
|
|
| |
This means a clearer message is now shown when patch.object is called with two string arguments, rather than a class and a string argument.
|
|
|
|
| |
(GH-17269)
|