From 8665769614183263a4370b35a4fdbe852e651e17 Mon Sep 17 00:00:00 2001 From: ROHAN WINSOR <61073765+rohanwinsor@users.noreply.github.com> Date: Fri, 15 Aug 2025 02:56:02 +0530 Subject: [PATCH] gh-137716: Fix double period in AttributeError message for invalid mock assertions (#137717) --- Lib/unittest/mock.py | 2 +- .../2025-08-13-16-58-58.gh-issue-137716.ZcZSyi.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-08-13-16-58-58.gh-issue-137716.ZcZSyi.rst 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 -- 2.47.3