From 298e3bafb8fe3963a9d0ac7b3e953d069643eb3d Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Wed, 6 Apr 2022 00:27:19 +0000 Subject: [PATCH] bpo-47235: Note where a typo is intentional in code. 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. --- Doc/library/unittest.mock.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index dbea928443975b..a3700ac07f1c1a 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -2550,7 +2550,7 @@ your assertion is gone: >>> mock = Mock(name='Thing', return_value=None) >>> mock(1, 2, 3) - >>> mock.assret_called_once_with(4, 5, 6) + >>> mock.assret_called_once_with(4, 5, 6) # Intentional typo! Your tests can pass silently and incorrectly because of the typo. @@ -2570,7 +2570,7 @@ attributes on the mock that exist on the real class: >>> from urllib import request >>> mock = Mock(spec=request.Request) - >>> mock.assret_called_with + >>> mock.assret_called_with # Intentional typo! Traceback (most recent call last): ... AttributeError: Mock object has no attribute 'assret_called_with' @@ -2582,7 +2582,7 @@ with any methods on the mock: >>> mock.has_data() - >>> mock.has_data.assret_called_with() + >>> mock.has_data.assret_called_with() # Intentional typo! Auto-speccing solves this problem. You can either pass ``autospec=True`` to :func:`patch` / :func:`patch.object` or use the :func:`create_autospec` function to create a @@ -2625,7 +2625,7 @@ any typos in our asserts will raise the correct error:: >>> req.add_header('spam', 'eggs') - >>> req.add_header.assret_called_with + >>> req.add_header.assret_called_with # Intentional typo! Traceback (most recent call last): ... AttributeError: Mock object has no attribute 'assret_called_with'