summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
Commit message (Collapse)AuthorAgeFilesLines
* [3.6] bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock ↵Miss Islington (bot)2018-12-111-11/+16
| | | | | | | | | | | tests (GH-8520) (GH-11032) (cherry picked from commit 3cf74384b53b998fa846dc2590cedf9ad2a0d5fd) Co-authored-by: Anirudha Bose <ani07nov@gmail.com> https://bugs.python.org/issue33747
* bpo-35330: Don't call the wrapped object if `side_effect` is set (GH11034)Miss Islington (bot)2018-12-081-0/+122
| | | | | | | | | | | | | | | | | | | | | | | | | * 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. (cherry picked from commit f05df0a4b679d0acfd0b1fe6187ba2d553b37afa) Co-authored-by: Mario Corchero <mariocj89@gmail.com>
* bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of ↵Miss Islington (bot)2018-12-042-2/+16
| | | | | | | | _Call/_MagicProxy. (GH-10873) Fix minor typo in test function name. (cherry picked from commit e63e617ebbe481c498bdf037a62e09f4f9f3963f) Co-authored-by: Andrew Dunai <andunai@gmail.com>
* bpo-35226: Fix equality for nested unittest.mock.call objects. (GH-10555)Miss Islington (bot)2018-12-032-0/+67
| | | | | | | Also refactor the call recording implementation and add some notes about its limitations. (cherry picked from commit 8ca0fa9d2f4de6e69f0902790432e0ab2f37ba68) Co-authored-by: Chris Withers <chris@withers.org>
* bpo-31177: Skip deleted attributes while calling reset_mock (GH-9302)Miss Islington (bot)2018-12-011-0/+10
| | | | | (cherry picked from commit edeca92c84a3b08902ecdfe987cde00c7e617887) Co-authored-by: Xtreak <tirkarthi@users.noreply.github.com>
* bpo-34900: Make TestCase.debug() work with subtests (GH-9707)Miss Islington (bot)2018-10-121-0/+14
| | | | | (cherry picked from commit da2bf9f66d0c95b988c5d87646d168f65499b316) Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
* bpo-33746: Fix test_unittest.testRegisterResult() in verbose mode (GH-7799)Miss Islington (bot)2018-06-201-9/+6
| | | | | | | | | | | | | | 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. (cherry picked from commit fd8fbce495c32b0cbc13f71a8e9d4eec6f48c844) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33748: fix tests altering sys.path and sys.modules (GH-7433) (GH-7603)Miss Islington (bot)2018-06-101-19/+20
| | | | | (cherry picked from commit 4ab4695388fb9ec03a14d93e90ce50d832a920ec) Co-authored-by: Tal Einat <taleinat+github@gmail.com>
* [3.6] bpo-32746: Fix multiple typos (GH-5144) (GH-5522)Terry Jan Reedy2018-02-041-2/+2
| | | | | | | | | Fix typos found by codespell in docs, docstrings, and comments. Fixes for the following files were in post-3.6 code and not backported: Lib/ctypes/_aix.py (new), Lib/test/test_concurrent_futures.py, Modules/_asynciomodule.c, Modules/_pickle.c, Objects/obmalloc.c. (cherry picked from commit c3d9508ff22ece9a96892b628dd5813e2fb0cd80)
* [3.6] bpo-32297: Fix misspellings in Python source code comments (GH-4803) ↵Andrew Svetlov2017-12-141-1/+1
| | | | | | | | | | | | | | (#4864) * [3.6] bpo-32297: Few misspellings found in Python source code comments. (GH-4803) * 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. (cherry picked from commit 53f7a7c2814fbfd8a29200926601a32fa48bacb3)
* [3.6] bpo-29403: Fix mock's broken autospec behavior on method-bound builtin ↵Berker Peksag2017-07-211-0/+15
| | | | | | | | | | | | | | | | | | | | | 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. (cherry picked from commit 856cbcc12f2e4cca93af5dc7ed6bcea4dd942f10)
* bpo-30813: Fix unittest when hunting refleaks (#2502) (#2505)Victor Stinner2017-06-301-0/+6
| | | | | | | 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. (cherry picked from commit e4f9a2d2be42d5a2cdd624f8ed7cdf5028c5fbc3)
* bpo-23890: Fix ref cycle in TestCase.assertRaises (#858)Victor Stinner2017-06-151-0/+13
| | | | | unittest.TestCase.assertRaises() now manually breaks a reference cycle to not keep objects alive longer than expected. (cherry picked from commit bbd3cf8f1ef1e91a8d6dac6411e18b4b9084abf5)
* bpo-28961: Address my comments from earlier code review (#306)Berker Peksag2017-02-261-12/+3
| | | (cherry picked from commit dea1536fd3a8424d537794cd53715df0989cbbe1)
* Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.Serhiy Storchaka2017-01-211-3/+14
|\
| * Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY.Serhiy Storchaka2017-01-211-3/+14
| |
* | Issue 29274: Merge doc fixes from 3.5Martin Panter2017-01-181-4/+4
|\ \ | |/
| * Issue #29274: tests cases → test casesMartin Panter2017-01-181-4/+4
| |
* | Fix unittest.mock._Call: don't ignore nameVictor Stinner2017-01-061-0/+14
| | | | | | | | | | | | | | Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter anymore. Patch written by Jiajun Huang.
* | Fixes issue28380: unittest.mock Mock autospec functions now properly supportGregory P. Smith2016-10-061-0/+6
| | | | | | | | assert_called, assert_not_called, and assert_called_once.
* | Issue #25651: Merge from 3.5Berker Peksag2016-09-211-0/+10
|\ \ | |/
| * Issue #25651: Allow falsy values to be used for msg parameter of subTest()Berker Peksag2016-09-211-0/+10
| |
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-072-2/+2
| |
* | #27364: fix "incorrect" uses of escape character in the stdlib.R David Murray2016-09-082-13/+13
| | | | | | | | | | | | | | And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-302-2/+2
| |
* | MergeRaymond Hettinger2016-08-261-1/+1
|\ \ | |/
| * Issue 19504: Change "customise" to "customize" American spelling.Raymond Hettinger2016-08-261-1/+1
| |
* | Issue #26750: unittest.mock.create_autospec() now works properly forGregory P. Smith2016-08-071-21/+39
|\ \ | |/ | | | | | | subclasses of property() and other data descriptors. Removes the never publicly used, never documented unittest.mock.DescriptorTypes tuple.
| * Issue #26750: unittest.mock.create_autospec() now works properlyGregory P. Smith2016-08-071-21/+39
| | | | | | | | for subclasses of property() and other data descriptors.
* | Issue #27430: Merge from 3.5Berker Peksag2016-07-011-1/+1
|\ \ | |/
| * Issue #27430: Fix typos, patch by scop.Berker Peksag2016-07-011-1/+1
| |
* | Issue #21271: Adds new keyword only parameters in reset_mock callKushal Das2016-06-021-0/+18
| | | | | | | | | | We now have two keyword only parameters in the reset_mock function to selectively reset the return_value or the side_effects, or both.
* | Issue #27063: Some unittest loader tests were silently skipped.Serhiy Storchaka2016-05-201-26/+28
|\ \ | |/
| * Issue #27063: Some unittest loader tests were silently skipped.Serhiy Storchaka2016-05-201-26/+28
| |
* | Issue #26807: mock_open 'files' no longer error on readline at end of file.Robert Collins2016-05-161-0/+12
|\ \ | |/ | | | | Patch from Yolanda Robla.
| * Issue #26807: mock_open 'files' no longer error on readline at end of file.Robert Collins2016-05-161-0/+12
| | | | | | | | Patch from Yolanda Robla.
* | Merge 3.5Serhiy Storchaka2016-04-251-0/+76
|\ \ | |/
| * Issue #26837: assertSequenceEqual() now correctly outputs non-stringifiedSerhiy Storchaka2016-04-251-0/+76
| | | | | | | | | | differing items (like bytes in the -b mode). This affects assertListEqual() and assertTupleEqual().
* | Issue #23277: Remove unused imports in tests.Serhiy Storchaka2016-04-242-3/+2
| |
* | Issue #23277: Remove unused sys and os importsBerker Peksag2016-04-241-2/+0
| | | | | | | | Patch by Jon Dufresne.
* | Merge 3.5 (test_unittest)Victor Stinner2016-03-291-3/+6
|\ \ | |/
| * Fix ResourceWarning in test_unittest when interruptedVictor Stinner2016-03-291-3/+6
| |
* | Issue #25195: Fix a regression in mock.MagicMockBerker Peksag2016-03-271-0/+17
|\ \ | |/ | | | | | | | | | | _Call is a subclass of tuple (changeset 3603bae63c13 only works for classes) so we need to implement __ne__ ourselves. Patch by Andrew Plummer.
| * Issue #25195: Fix a regression in mock.MagicMockBerker Peksag2016-03-271-0/+17
| | | | | | | | | | | | | | _Call is a subclass of tuple (changeset 3603bae63c13 only works for classes) so we need to implement __ne__ ourselves. Patch by Andrew Plummer.
* | #25320: Handle sockets in directories unittest discovery is scanning.Robert Collins2016-03-151-0/+40
|\ \ | |/ | | | | Patch from Victor van den Elzen.
| * #25320: Handle sockets in directories unittest discovery is scanning.Robert Collins2016-03-151-0/+40
| | | | | | | | Patch from Victor van den Elzen.
* | Add Mock.assert_called()Victor Stinner2016-03-111-0/+21
|/ | | | | Issue #26323: Add assert_called() and assert_called_once() methods to unittest.mock.Mock.
* Issue #22138: Fix mock.patch behavior when patching descriptors. RestoreSenthil Kumaran2016-01-091-0/+26
| | | | | | original values after patching. Patch contributed by Sean McCully.
* Issue #25523: Further a-to-an corrections new in 3.5Martin Panter2015-11-021-2/+2
|
* Issue #24857: Comparing call_args to a long sequence now correctly returns aBerker Peksag2015-09-091-0/+3
|\ | | | | | | | | | | boolean result instead of raising an exception. Patch by A Kaptur.