summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix typo in test comment (GH-11442)Ashwin Ramaswami2019-05-191-1/+1
|
* bpo-24758: Improve the error msg for unittest.mock.Mock()'s unsafe mode (#12991)Zackery Spytz2019-05-082-3/+5
| | | | | | * bpo-24758: Improve the error msg for unittest.mock.Mock()'s unsafe mode * Make the requested changes.
* bpo-31855: unittest.mock.mock_open() results now respects the argument of ↵Rémi Lapeyre2019-05-072-26/+20
| | | | | | | | read([size]) (GH-11521) unittest.mock.mock_open() results now respects the argument of read([size]) Co-Authored-By: remilapeyre <remi.lapeyre@henki.fr>
* bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)Serhiy Storchaka2019-05-061-1/+4
|
* Mock 100% coverage (GH-13045)Chris Withers2019-05-019-317/+263
| | | | | | | | | | | 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.
* remove jython support from unittest.mock (GH#13033)Chris Withers2019-05-013-25/+2
|
* Don't report deleted attributes in __dir__ (GH#10148)Mario Corchero2019-04-302-2/+13
| | | | | | 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).
* bpo-36751: Deprecate getfullargspec and report positional-only args as ↵Pablo Galindo2019-04-301-2/+2
| | | | | | | | regular args (GH-13016) * bpo-36751: Deprecate getfullargspec and report positional-only args as regular args * Use inspect.signature in testhelpers
* Document that TestCase.assertCountEqual() can take iterables (GH-686)jkleint2019-04-231-3/+2
|
* bpo-23078: Add support for {class,static}method to mock.create_autospec() ↵Xtreak2019-04-224-2/+79
| | | | | (GH-11613) Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
* bpo-36593: Fix isinstance check for Mock objects with spec executed under ↵Xtreak2019-04-132-1/+39
| | | | | 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 .
* bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)Serhiy Storchaka2019-04-012-3/+101
| | | | | | | | | | | | | | | | | | | | | | Deprecated passing the following arguments as keyword arguments: - "func" in functools.partialmethod(), weakref.finalize(), profile.Profile.runcall(), cProfile.Profile.runcall(), bdb.Bdb.runcall(), trace.Trace.runfunc() and curses.wrapper(). - "function" in unittest.addModuleCleanup() and unittest.TestCase.addCleanup(). - "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor and concurrent.futures.ProcessPoolExecutor. - "callback" in contextlib.ExitStack.callback(), contextlib.AsyncExitStack.callback() and contextlib.AsyncExitStack.push_async_callback(). - "c" and "typeid" in the create() method of multiprocessing.managers.Server and multiprocessing.managers.SharedMemoryServer. - "obj" in weakref.finalize(). Also allowed to pass arbitrary keyword arguments (even "self" and "func") if the above arguments are passed as positional argument.
* bpo-36366: Return None on stopping unstarted patch object (GH-12472)Xtreak2019-03-282-3/+11
| | | | | | Return None after calling unittest.mock.patch.object.stop() regardless of whether the object was started. This makes the method idempotent. https://bugs.python.org/issue36366
* bpo-21269: Provide args and kwargs attributes on mock call objects GH11807Kumar Akshay2019-03-223-3/+33
|
* Autospec functions should propagate mock calls to parent GH-11273Xtreak2019-02-252-0/+21
|
* bpo-35512: Resolve string target to patch.dict decorator during function ↵Xtreak2019-02-243-2/+22
| | | | | | | | | | | | | | call GH#12000 * Resolve string target to patch.dict during function call * Add NEWS entry * Remove unneeded call * Restore original value for support.target and refactor assertions * Add extra assertion to verify unpatched dict
* bpo-35500: align expected and actual calls on mock.assert_called_with error ↵Susan Su2019-02-142-9/+13
| | | | message. (GH-11804)
* bpo-35767: Fix unittest.loader to allow partials as test_functions (#11600)Jason Fried2019-01-232-1/+19
|
* bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (#11057)Pablo Galindo2019-01-212-4/+30
| | | | | | | | * 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
* Fix mock_open docstring to use readline (#11176)Xtreak2018-12-201-1/+1
|
* bpo-35513, unittest: TextTestRunner uses time.perf_counter() (GH-11180)Victor Stinner2018-12-171-2/+2
| | | | | | | TextTestRunner of unittest.runner now uses time.perf_counter() rather than time.time() to measure the execution time of a test: time.time() can go backwards, whereas time.perf_counter() is monotonic. Similar change made in libregrtest, pprint and random.
* Add test for double patching instance methods (#11085)Anthony Sottile2018-12-121-0/+14
|
* bpo-17185: Add __signature__ to mock that can be used by inspect for ↵Xtreak2018-12-122-2/+34
| | | | | | | | | | | | | | | | signature (GH11048) * Fix partial and partial method signatures in mock * Add more calls * Add NEWS entry * Use assertEquals and fix markup in NEWS * Refactor branching and add markup reference for functools * Revert partial object related changes and fix pr comments
* bpo-35330: Don't call the wrapped object if `side_effect` is set (GH10973)Mario Corchero2018-12-082-11/+132
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock tests ↵Anirudha Bose2018-12-071-11/+16
| | | | (GH-8520)
* Remove unused function in `testmock/support.py` (GH-10975)Mario Corchero2018-12-061-7/+0
| | | | The function is never imported and the implementation is actually buggy. As `warnings.catch_warnings` is not imported here.
* bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of ↵Andrew Dunai2018-12-043-16/+30
| | | | | _Call/_MagicProxy. (#10873) Fix minor typo in test function name.
* bpo-35226: Fix equality for nested unittest.mock.call objects. (#10555)Chris Withers2018-12-033-23/+99
| | | | Also refactor the call recording imolementation and add some notes about its limitations.
* bpo-32153: Add unit test for create_autospec with partial function returned ↵Xtreak2018-12-031-0/+14
| | | | | | | | | | in getattr (#10398) * Add create_autospec with partial function returned in getattr * Use self.assertFalse instead of assert * Use different names and remove object
* bpo-31177: Skip deleted attributes while calling reset_mock (GH-9302)Xtreak2018-12-012-1/+11
|
* Use assertEqual to fix DeprecationWarning. (GH-10794)Xtreak2018-11-291-1/+1
|
* bpo-24412: Adds cleanUps for setUpClass and setUpModule. (GH-9190)Lisa Roach2018-11-094-18/+705
|
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Serhiy Storchaka2018-11-051-1/+1
| | | | | | | | | | (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.
* bpo-35047, unittest.mock: Better error messages on assert_called_xxx ↵Petter Strandmark2018-10-282-8/+58
| | | | | | | 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.
* bpo-35022: unittest.mock.MagicMock now also supports __fspath__ (GH-9960)Max Bélanger2018-10-252-0/+12
| | | | 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.
* unittest.mock doc: Fix references to recursive seal of Mocks (GH-9028)Mario Corchero2018-10-191-5/+4
| | | | | The docs in `library/unittest.mock` have been updated to remove confusing terms about submock and be explicit about the behavior expected.
* bpo-34900: Make TestCase.debug() work with subtests (GH-9707)Bruno Oliveira2018-10-122-1/+15
|
* bpo-32933: Implement __iter__ method on mock_open() (GH-5974)Tony Flury2018-09-123-3/+31
|
* bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. ↵Serhiy Storchaka2018-08-192-19/+10
| | | | (GH-8623)
* Improve error message when mock.assert_has_calls fails (GH-8205)davidair2018-08-171-1/+3
| | | | | This makes the assertion error message more useful, aiding debugging. Thanks @davidair!
* bpo-33746: Fix test_unittest.testRegisterResult() in verbose mode (GH-7799)Victor Stinner2018-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.
* pypi.python.org -> pypi.org (GH-7613)Ned Deily2018-06-111-1/+1
|
* bpo-33748: fix tests altering sys.path and sys.modules (GH-7433)Tal Einat2018-06-101-19/+20
|
* bpo-33516: Add support for __round__ in MagicMock (GH-6880)John Reese2018-05-222-1/+6
| | | unittest.mock.MagicMock now supports the __round__() magic method.
* bpo-32746: Fix multiple typos (GH-5144)Leo Arias2018-02-041-2/+2
| | | Fix typos found by codespell in docs, docstrings, and comments.
* bpo-32360: unittest.util: Use Counter instead of custom count function (GH-4994)Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి)2018-01-241-9/+2
|
* bpo-32593: Drop FreeBSD 9 and older support (#5232)Victor Stinner2018-01-221-8/+0
| | | Drop support of FreeBSD 9 and older.
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * 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
* bpo-32230: Set sys.warnoptions with -X dev (#4820)Victor Stinner2017-12-121-1/+1
| | | | | | | | | | | | | | 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 regression and add What's New entry (#4589)Jonas Haag2017-11-282-2/+26
| | | | | | * bpo-32071: Fix an undocumented behaviour regression * bpo-32071: Add 3.7 release note entry for unittest -k