From: ROHAN WINSOR <61073765+rohanwinsor@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:26:02 +0000 (+0530) Subject: gh-137716: Fix double period in AttributeError message for invalid mock assertions... X-Git-Tag: v3.15.0a1~682 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8665769614183263a4370b35a4fdbe852e651e17;p=thirdparty%2FPython%2Fcpython.git gh-137716: Fix double period in AttributeError message for invalid mock assertions (#137717) --- diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index e1dbfdacf563..0bb675065538 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -700,7 +700,7 @@ class NonCallableMock(Base): if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST: raise AttributeError( f"{name!r} is not a valid assertion. Use a spec " - f"for the mock if {name!r} is meant to be an attribute.") + f"for the mock if {name!r} is meant to be an attribute") with NonCallableMock._lock: result = self._mock_children.get(name) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-08-13-16-58-58.gh-issue-137716.ZcZSyi.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-08-13-16-58-58.gh-issue-137716.ZcZSyi.rst new file mode 100644 index 000000000000..82d8e1577905 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-08-13-16-58-58.gh-issue-137716.ZcZSyi.rst @@ -0,0 +1 @@ +Fix double period in :exc:`AttributeError` message for invalid mock assertions