| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Fixes an issue caught after merge of PR 16005.
Tightened test assertions to check the entire assertion message.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The fix in PR 13261 handled the underlying issue about the spec for specific methods not being applied correctly, but it didn't fix the issue that was causing the misleading error message.
The code currently grabs a list of responses from _call_matcher (which may include exceptions). But it doesn't reach inside the list when checking if the result is an exception. This results in a misleading error message when one of the provided calls does not match the spec.
https://bugs.python.org/issue36871
Automerge-Triggered-By: @gpshead
|
| |
|
|
|
|
| |
In the format string for assert_called the evaluation order is incorrect and hence for mock's without name, 'None' is printed whereas it should be 'mock' like for other messages. The error message is ("Expected '%s' to have been called." % self._mock_name or 'mock').
|
|
|
|
| |
messages (GH-14310)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
method (GH13261)
* Fix call_matcher for mock when using methods
* Add NEWS entry
* Use None check and convert doctest to unittest
* Use better name for mock in tests. Handle _SpecState when the attribute was not accessed and add tests.
* Use reset_mock instead of reinitialization. Change inner class constructor signature for check
* Reword comment regarding call object lookup logic
|
|
|
|
| |
They now return NotImplemented for unsupported type of the other operand.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix typos in comments, docs and test names
* Update test_pyparse.py
account for change in string length
* Apply suggestion: splitable -> splittable
Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>
* Apply suggestion: splitable -> splittable
Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>
* Apply suggestion: Dealloccte -> Deallocate
Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>
* Update posixmodule checksum.
* Reverse idlelib changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
with attach_mock (GH 14688)
* Clear name and parent of mock in autospecced objects used with attach_mock
* Add NEWS entry
* Fix reversed order of comparison
* Test child and standalone function calls
* Use a helper function extracting mock to avoid code duplication and refactor tests.
|
|
|
|
|
|
|
|
| |
I've reported the issue on https://bugs.python.org/issue37008 and now I'm trying to bring a solution to this minor issue.
I think it could be trivially backported to 3.7 branch.
https://bugs.python.org/issue37008
|
| |
|
|
|
|
|
|
| |
* bpo-24758: Improve the error msg for unittest.mock.Mock()'s unsafe mode
* Make the requested changes.
|
|
|
|
|
|
|
|
|
|
|
| |
This was achieved by:
* moving many pass statements in tests onto their own lines, so they pass line coverage and can match an easy ignore pattern if branch coverage is added later.
* removing code that cannot be reached.
* removing long-disabled tests.
* removing unused code.
* adding tests for uncovered code
It turned out that removing `if __name__ == '__main__'` blocks that run unittest.main() at the bottom of test files was surprisingly contentious, so they remain and can be filtered out with an appropriate .coveragerc.
|
| |
|
|
|
|
|
|
| |
When an attribute is deleted from a Mock, a sentinel is added rather
than just deleting the attribute. This commit checks for such sentinels
when returning the child mocks in the __dir__ method as users won't
expect deleted attributes to appear when performing dir(mock).
|
|
|
|
|
| |
(GH-11613)
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
|
|
|
|
|
| |
tracing (GH-12790)
In Python having a trace function in effect while mock is imported causes isinstance to be wrong for MagicMocks. This is due to the usage of super() in some class methods, as this sets the __class__ attribute. To avoid this, as a workaround, alias the usage of super .
|
| |
|
| |
|
|
|
|
| |
message. (GH-11804)
|
|
|
|
|
|
|
|
| |
* Allow repeated deletion of unittest.mock.Mock attributes
* fixup! Allow repeated deletion of unittest.mock.Mock attributes
* fixup! fixup! Allow repeated deletion of unittest.mock.Mock attributes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* tests: Further validate `wraps` functionality in `unittest.mock.Mock`
Add more tests to validate how `wraps` interacts with other features of
mocks.
* Don't call the wrapped object if `side_effect` is set
When a object is wrapped using `Mock(wraps=...)`, if an user sets a
`side_effect` in one of their methods, return the value of `side_effect`
and don't call the original object.
* Refactor what to be called on `mock_call`
When a `Mock` is called, it should return looking up in the following
order: `side_effect`, `return_value`, `wraps`. If any of the first two
return `mock.DEFAULT`, lookup in the next option.
It makes no sense to check for `wraps` returning default, as it is
supposed to be the original implementation and there is nothing to
fallback to.
|
|
|
|
|
| |
_Call/_MagicProxy. (#10873)
Fix minor typo in test function name.
|
|
|
|
| |
Also refactor the call recording imolementation and add some notes
about its limitations.
|
| |
|
|
|
|
|
|
|
| |
failures (GH-10090)
unittest.mock now includes mock calls in exception messages if
assert_not_called, assert_called_once, or assert_called_once_with
fails.
|
| |
|
|\ |
|
| | |
|
| |
| |
| |
| |
| | |
We now have two keyword only parameters in the reset_mock function to
selectively reset the return_value or the side_effects, or both.
|
|\ \
| |/
| |
| | |
Patch from Yolanda Robla.
|
| |
| |
| |
| | |
Patch from Yolanda Robla.
|
|\ \
| |/
| |
| |
| |
| |
| | |
_Call is a subclass of tuple (changeset 3603bae63c13 only works
for classes) so we need to implement __ne__ ourselves.
Patch by Andrew Plummer.
|
| |
| |
| |
| |
| |
| |
| | |
_Call is a subclass of tuple (changeset 3603bae63c13 only works
for classes) so we need to implement __ne__ ourselves.
Patch by Andrew Plummer.
|
|/
|
|
|
| |
Issue #26323: Add assert_called() and assert_called_once() methods to
unittest.mock.Mock.
|
|\
| |
| |
| |
| |
| | |
boolean result instead of raising an exception.
Patch by A Kaptur.
|
| |
| |
| |
| |
| |
| | |
boolean result instead of raising an exception.
Patch by A Kaptur.
|
|\ \
| |/ |
|
| | |
|
|\ \
| |/
| |
| | |
could in Python 3.3.
|
| |
| |
| |
| | |
could in Python 3.3.
|
|\ \
| |/
| |
| | |
Patch from Nicola Palumbo and Laurent De Buyst.
|
| |
| |
| |
| | |
Patch from Nicola Palumbo and Laurent De Buyst.
|
| |
| |
| |
| | |
This was a regression vs Python 3.4. Patch from Ignacio Rossi
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
Printout of keyword args should be in deterministic order in
a mock function call. This will help to write better doctests.
|
| |
| |
| |
| | |
It raises AssertionError if the mock has been called.
|
|/
|
|
|
| |
It raises `AttributeError` incase of an attribute startswith assert
or assret.
|
|
|
|
| |
Passing name keyword argument to mock.create_autospec now works.
|