| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
(GH-8520)
|
|
|
|
| |
The function is never imported and the implementation is actually buggy.
As `warnings.catch_warnings` is not imported here.
|
|
|
|
|
| |
_Call/_MagicProxy. (#10873)
Fix minor typo in test function name.
|
|
|
|
| |
Also refactor the call recording imolementation and add some notes
about its limitations.
|
|
|
|
|
|
|
|
|
|
| |
in getattr (#10398)
* Add create_autospec with partial function returned in getattr
* Use self.assertFalse instead of assert
* Use different names and remove object
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
(GH-10284)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
The MagicMock class supports many magic methods, but not __fspath__. To ease
testing with modules such as os.path, this function is now supported by default.
|
|
|
|
|
| |
The docs in `library/unittest.mock` have been updated to remove
confusing terms about submock and be explicit about the behavior
expected.
|
| |
|
| |
|
|
|
|
| |
(GH-8623)
|
|
|
|
|
| |
This makes the assertion error message more useful, aiding debugging.
Thanks @davidair!
|
|
|
|
|
|
|
|
|
|
|
| |
Only make sure that the result is in unittest.signals._results, don't
check the full content of unittest.signals._results.
support._run_suite() uses TextTestRunner in verbose mode, but
TextTestRunner.run() calls registerResult(result) which made the test
fail with "odd object in result set".
Call also removeResult() to restore unittest.signals._results to
avoid test side effect.
|
| |
|
| |
|
|
|
| |
unittest.mock.MagicMock now supports the __round__() magic method.
|
|
|
| |
Fix typos found by codespell in docs, docstrings, and comments.
|
| |
|
|
|
| |
Drop support of FreeBSD 9 and older.
|
|
|
|
|
|
|
|
| |
* Fix multiple typos in code comments
* Add spacing in comments (test_logging.py, test_math.py)
* Fix spaces at the beginning of comments in test_logging.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than supporting dev mode directly in the warnings module, this
instead adjusts the initialisation code to add an extra 'default'
entry to sys.warnoptions when dev mode is enabled.
This ensures that dev mode behaves *exactly* as if `-Wdefault` had
been passed on the command line, including in the way it interacts
with `sys.warnoptions`, and with other command line flags like `-bb`.
Fix also bpo-20361: have -b & -bb options take precedence over any
other warnings options.
Patch written by Nick Coghlan, with minor modifications of Victor Stinner.
|
|
|
|
|
|
| |
* bpo-32071: Fix an undocumented behaviour regression
* bpo-32071: Add 3.7 release note entry for unittest -k
|
|
|
|
| |
* bpo-32071: Add unittest -k option
|
| |
|
|
|
|
| |
The word "difference" from missing the sentence.
This clarifies that it compares the difference between the two objects.
|
|
|
|
|
|
|
| |
The new method allows the developer to control when to stop the
feature of mocks that automagically creates new mocks when accessing
an attribute that was not declared before
Signed-off-by: Mario Corchero <mariocj89@gmail.com>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
functions (GH-3)
Cython will, in the right circumstances, offer a MethodType instance
where im_func is a builtin function. Any instance of MethodType is
automatically assumed to be a Python-defined function (more
specifically, a function that has an inspectable signature), but
_set_signature was still conservative in its assumptions. As a result
_set_signature would return early with None instead of a mock since
the im_func had no inspectable signature. This causes problems
deeper inside mock, as _set_signature is assumed to _always_
return a mock, and nothing checked its return value.
In similar corner cases, autospec will simply not check the spec of the
function, so _set_signature is amended to now return early with the
original, not-wrapped mock object.
Patch by Aaron Gallagher.
|
|
|
|
|
|
| |
bpo-11798, bpo-16662, bpo-16935, bpo-30813: Skip
test_discover_with_module_that_raises_SkipTest_on_import() and
test_discover_with_init_module_that_raises_SkipTest_on_import() of
test_unittest when hunting reference leaks using regrtest.
|
|
|
|
| |
order of keyword arguments of TestCase.subTest().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* #30190 / unittest / assertAlmostEqual(delta=...) / error msg: show the difference between the 2 numbers in case of failure
* safe_repr() diff
* also show difference when passing 'places' argument
* refactoring
* update Misc/NEWS
|
| |
|
| |
|
|
|
|
| |
bpo-23890: unittest.TestCase.assertRaises() now manually breaks a
reference cycle to not keep objects alive longer than expected.
|
|
|
| |
Make also minor PEP8 coding style fixes on modified imports.
|
| |
|
| |
|
|\ |
|
| |\ |
|
| | | |
|
|\ \ \
| |/ / |
|
| |\ \
| | |/ |
|
| | | |
|