summaryrefslogtreecommitdiffstats
path: root/Doc/library/unittest.mock.rst
Commit message (Collapse)AuthorAgeFilesLines
* GH-101100: Fix reference warnings for ``__enter__`` and ``__exit__`` (#110112)Adam Turner2023-10-191-2/+2
|
* GH-101100: Fix reference warnings for ``__getitem__`` (#110118)Adam Turner2023-10-191-1/+1
|
* gh-110631: Fix reST indentation in `Doc/library` (#110685)Ezio Melotti2023-10-111-5/+5
| | | Fix wrong indentation in the Doc/library dir.
* Fix typos in docs and comments (#109619)Heinz-Alexander Fuetterer2023-09-201-1/+1
|
* gh-109350: Fix outdated captured output in unittest.mock documentation (#109353)Egil Martinsson2023-09-151-4/+6
|
* gh-106909: Use role :const: for referencing module constants (GH-106910)Serhiy Storchaka2023-07-211-1/+1
|
* gh-61215: Rename `wait_until_any_call` to `wait_until_any_call_with` (#106414)Mario Corchero2023-07-041-2/+2
| | | | | | 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.
* gh-61215: New mock to wait for multi-threaded events to happen (#16094)Mario Corchero2023-07-031-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add import of `unittest.mock.Mock` in documentation (#102346)Wagner Alberto2023-03-031-0/+1
|
* Correct trivial grammar in reset_mock docs (#101861)Steve Kowalik2023-02-131-3/+3
|
* gh-99087: Add missing newline for prompts in docs (GH-98993)Stanley2022-12-091-0/+1
| | | Add newline for prompts so copying to REPL does not cause errors.
* gh-93851: Fix all broken links in Doc/ (GH-93853)Oleg Iarygin2022-06-211-1/+1
|
* gh-92417: `unittest.mock` docs: remove references to Python <2.6 (GH-92539)Alex Waygood2022-05-101-1/+1
|
* bpo-47235: Note where a typo is intentional in code. (GH-32348)Gregory P. Smith2022-04-061-4/+4
| | | | | | | | | | | People keep popping up reporting these as typos in the docs despite being described as typos in the surrounding text. Hopefully a comment on the line itself makes it more obvious? Arguably some of the typo examples are not using the "right" typo as the "assret" one in particular is now detected by default due to how common it was in actual code. But I don't want to to typo chasing by changing these examples to be other not yet auto-detected typos as they still illustrate the point well enough.
* bpo-46852: Remove the float.__set_format__() method (GH-31585)Victor Stinner2022-02-251-1/+1
| | | | | | Remove the undocumented private float.__set_format__() method, previously known as float.__set_format__() in Python 3.7. Its docstring said: "You probably don't want to use this function. It exists mainly to be used in Python's test suite."
* doc: fix a typo in unittest.mock.rst (GH-30227)Joe2021-12-261-1/+1
|
* bpo-45010: Remove support of special method __div__ in unittest.mock (GH-27965)Serhiy Storchaka2021-08-261-1/+1
|
* bpo-44679: [doc] fix typo in unittest.mock.rst (GH-27618)Jack DeVries2021-08-051-1/+1
|
* bpo-44534: fix wording and docstring sync in unittest.Mock GH27000Jack DeVries2021-07-051-1/+1
|
* Remove duplicate words in docs. (GH-26167)Mariusz Felisiak2021-05-211-2/+2
|
* bpo-43400: Remove "easy to use" from mock docs (GH-24752)Eddie Peters2021-03-041-1/+1
|
* bpo-41877: Improve docs for assert misspellings check in mock (GH-23729)vabr-g2020-12-101-3/+4
| | | | | | | | | This is a follow-up to https://github.com/python/cpython/commit/4662fa9bfe4a849fe87bfb321d8ef0956c89a772. That original commit expanded guards against misspelling assertions on mocks. This follow-up updates the documentation and improves the error message by pointing out the potential cause and solution. Automerge-Triggered-By: GH:gpshead
* bpo-41325: Add version note for args and kwargs property in call object ↵Jordan Speicher2020-07-181-0/+3
| | | | (GH-21525)
* Remove note saying patch is straightforward (#18431)Brian Curtin2020-02-101-2/+1
| | | | | | | While `unittest.mock.patch` is a great thing, it is not straightforward. If it were straightforward there wouldn't be such a huge amount of documentation for it, and frankly, when myself and others who I've read about often struggle to figure out what on earth `patch()` wants, coming to the docs to read that it's straightforward is not helpful.
* bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521)Paulo Henrique Silva2020-01-251-1/+2
|
* Fix AsyncMock base class in the docs (GH-18008)Elena Oat2020-01-151-1/+1
|
* bpo-38857: AsyncMock fix for awaitable values and StopIteration fix [3.8] ↵Jason Fried2019-11-211-1/+1
| | | | (GH-17269)
* bpo-38753: AsyncMock added in version 3.8 (GH-17102)John Belmonte2019-11-201-0/+1
|
* bpo-38738: Fix formatting of True and False. (GH-17083)Serhiy Storchaka2019-11-121-17/+17
| | | | | | | | | * "Return true/false" is replaced with "Return ``True``/``False``" if the function actually returns a bool. * Fixed formatting of some True and False literals (now in monospace). * Replaced "True/False" with "true/false" if it can be not only bool. * Replaced some 1/0 with True/False if it corresponds the code. * "Returns <bool>" is replaced with "Return <bool>".
* bpo-38163: Child mocks detect their type as sync or async (GH-16471)Lisa Roach2019-09-301-1/+27
|
* bpo-38136: Updates await_count and call_count to be different things (GH-16192)Lisa Roach2019-09-241-24/+13
|
* bpo-35685: Add examples of unittest.mock.patch.dict usage (GH-11456)Emmanuel Arias2019-09-121-4/+27
|
* bpo-37383: Updates docs to reflect AsyncMock call_count after await. (#15761)Lisa Roach2019-09-091-0/+14
| | | | | | | | | | * bpo-351428: Updates documentation to reflect AsyncMock call_count after await. * Adds skip and fixes warning. * Removes extra >>>. * Adds ... in front of await mock().
* docs: Add references to AsyncMock in unittest.mock.patch (#13681)Mario Corchero2019-09-091-4/+16
| | | | Update the docs as patch can now return an AsyncMock if the patched object is an async function.
* bpo-35946: Improve assert_called_with documentation (GH-11796)Rémi Lapeyre2019-08-291-2/+2
|
* Fix docs for assert_called and assert_called_once (#15197)Ismail S2019-08-121-2/+2
|
* bpo-37075: Fix string concatenation in assert_has_awaits error message ↵Xtreak2019-05-291-1/+2
| | | | | | | | | | (GH-13616) * Fix the implicit string concatenation in `assert_has_awaits` error message. * Use "await" instead of "call" in `assert_awaited_with` error message. https://bugs.python.org/issue37075
* bpo-32299: Return patched dict when using patch.dict as a context manager ↵Mario Corchero2019-05-281-1/+10
| | | | | | (GH-11062)
* bpo-37047: Refactor AsyncMock setup logic for autospeccing (GH-13574)Xtreak2019-05-271-1/+5
| | | | Handle late binding and attribute access in unittest.mock.AsyncMock setup for autospeccing.
* Fix RuntimeWarning in unittest.mock asyncio example (GH-13449)Xtreak2019-05-211-2/+2
| | | | * This PR fixes the `RuntimeWarning` in `inspect.isawaitable(mock())` where `mock()` was not awaited. * Fix typo in asynctest project.
* bpo-26467: Adds AsyncMock for asyncio Mock library support (GH-9296)Lisa Roach2019-05-201-1/+214
|
* bpo-21269: Provide args and kwargs attributes on mock call objects GH11807Kumar Akshay2019-03-221-8/+17
|
* Fix typo in unittest.mock documentation: manger -> manager (GH-12352)Joan Massich2019-03-171-1/+1
|
* Add example to the documentation for calling unittest.mock.patch with ↵Pablo Galindo2019-01-091-7/+28
| | | | create=True (GH-11056)
* bpo-35226: Fix equality for nested unittest.mock.call objects. (#10555)Chris Withers2018-12-031-0/+13
| | | | Also refactor the call recording imolementation and add some notes about its limitations.
* bpo-35022: unittest.mock.MagicMock now also supports __fspath__ (GH-9960)Max Bélanger2018-10-251-0/+4
| | | | 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-4/+5
| | | | | The docs in `library/unittest.mock` have been updated to remove confusing terms about submock and be explicit about the behavior expected.
* bpo-34962: make doctest in Doc/ now passes, and is enforced in CI (GH-9806)Stéphane Wirtel2018-10-121-32/+68
|
* Fix "Python" casing in a few places (GH-9001)Andrés Delfino2018-09-141-1/+1
|
* bpo-32933: Implement __iter__ method on mock_open() (GH-5974)Tony Flury2018-09-121-0/+4
|