| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#30196)
* Strip IsolatedAsyncioTestCase frames from reported stacktraces
* Update Misc/NEWS.d/next/Library/2021-12-19-10-47-24.bpo-46128.Qv3EK1.rst
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
---------
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
|
| |
|
|
|
|
| |
directory (#123820)
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Deprecate `asyncio.iscoroutinefunction` in favor of `inspect.iscoroutinefunction`.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
| |
`create_autospec` (#120737)
|
|
|
|
|
| |
Tools such as ruff can ignore "imported but unused" warnings if a
line ends with "# noqa: F401". It avoids the temptation to remove
an import which is used effectively.
|
|
|
|
|
|
| |
(#120401)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
| |
NonCallableMock.__setattr__ (#120019)
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As reported in #117847 and #115366, an unpaired backtick in a docstring
tends to confuse e.g. Sphinx running on subclasses of standard library
objects, and the typographic style of using a backtick as an opening
quote is no longer in favor. Convert almost all uses of the form
The variable `foo' should do xyz
to
The variable 'foo' should do xyz
and also fix up miscellaneous other unpaired backticks (extraneous /
missing characters).
No functional change is intended here other than in human-readable
docstrings.
|
| |
|
| |
|
|
|
|
| |
avoid leap-year bugs (GH-117107)
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
| |
(#106588)" (GH-114470)
This reverts commit 8fc071345b50dd3de61ebeeaa287ccef21d061b2.
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
docstrings (GH-113408)
|
|
|
|
|
|
|
| |
IsolatedAsyncioTestCase (#110776)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
|
|
|
|
| |
Align expected and actual titles in output from
assert_has_calls/assert_called_with for greater readability
|
|
|
|
|
| |
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
| |
|
| |
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
| |
threadingmock: Remove unused branch for `timeout`
This is no longer needed as the mock does not hold a "timeout"
parameter, the timeout is stored in `_mock_wait_timeout`.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
`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
|
| |
|
| |
|
|
|
|
| |
findTestCases (#104836)
|
|
|
|
| |
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
|
| |
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
address review comments to PR-12271
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
|
|
|
|
|
|
|
| |
decorators (#103228)
Fixes unittest.mock.patch not enforcing function signatures for methods
decorated with @classmethod or @staticmethod when patch is called with
autospec=True.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|