From 0cb765b2cec9b020224af016a83bf35c45b71932 Mon Sep 17 00:00:00 2001 From: Alex-Blade <44120047+Alex-Blade@users.noreply.github.com> Date: Wed, 16 Feb 2022 10:07:34 +0300 Subject: bpo-46730: Add more info to @property AttributeError messages (GH-31311) On `obj.read_only_property = x`, raise `AttributeError: property 'read_only_property' of 'A' object has no setter`. --- Lib/test/test_property.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Lib/test/test_property.py') diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 7f3813fc8c..7d1c4a1e12 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -322,27 +322,27 @@ class _PropertyUnreachableAttribute: cls.obj = cls.cls() def test_get_property(self): - with self.assertRaisesRegex(AttributeError, self._format_exc_msg("unreadable attribute")): + with self.assertRaisesRegex(AttributeError, self._format_exc_msg("has no getter")): self.obj.foo def test_set_property(self): - with self.assertRaisesRegex(AttributeError, self._format_exc_msg("can't set attribute")): + with self.assertRaisesRegex(AttributeError, self._format_exc_msg("has no setter")): self.obj.foo = None def test_del_property(self): - with self.assertRaisesRegex(AttributeError, self._format_exc_msg("can't delete attribute")): + with self.assertRaisesRegex(AttributeError, self._format_exc_msg("has no deleter")): del self.obj.foo class PropertyUnreachableAttributeWithName(_PropertyUnreachableAttribute, unittest.TestCase): - msg_format = "^{} 'foo'$" + msg_format = r"^property 'foo' of 'PropertyUnreachableAttributeWithName\.cls' object {}$" class cls: foo = property() class PropertyUnreachableAttributeNoName(_PropertyUnreachableAttribute, unittest.TestCase): - msg_format = "^{}$" + msg_format = "^property of 'PropertyUnreachableAttributeNoName\.cls' object {}$" class cls: pass -- cgit v1.2.1