Skip to content

Commit c0f6a2f

Browse files
committed
Update test_abc.py from CPython v3.12.0
1 parent 9953151 commit c0f6a2f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Lib/test/test_abc.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class C(metaclass=abc_ABCMeta):
154154
@abc.abstractmethod
155155
def method_one(self):
156156
pass
157-
msg = r"class C with abstract method method_one"
157+
msg = r"class C without an implementation for abstract method 'method_one'"
158158
self.assertRaisesRegex(TypeError, msg, C)
159159

160160
def test_object_new_with_many_abstractmethods(self):
@@ -165,7 +165,7 @@ def method_one(self):
165165
@abc.abstractmethod
166166
def method_two(self):
167167
pass
168-
msg = r"class C with abstract methods method_one, method_two"
168+
msg = r"class C without an implementation for abstract methods 'method_one', 'method_two'"
169169
self.assertRaisesRegex(TypeError, msg, C)
170170

171171
def test_abstractmethod_integration(self):
@@ -448,15 +448,16 @@ class S(metaclass=abc_ABCMeta):
448448

449449
# Also check that issubclass() propagates exceptions raised by
450450
# __subclasses__.
451+
class CustomError(Exception): ...
451452
exc_msg = "exception from __subclasses__"
452453

453454
def raise_exc():
454-
raise Exception(exc_msg)
455+
raise CustomError(exc_msg)
455456

456457
class S(metaclass=abc_ABCMeta):
457458
__subclasses__ = raise_exc
458459

459-
with self.assertRaisesRegex(Exception, exc_msg):
460+
with self.assertRaisesRegex(CustomError, exc_msg):
460461
issubclass(int, S)
461462

462463
def test_subclasshook(self):
@@ -521,6 +522,7 @@ def foo(self):
521522
self.assertEqual(A.__abstractmethods__, set())
522523
A()
523524

525+
524526
def test_update_new_abstractmethods(self):
525527
class A(metaclass=abc_ABCMeta):
526528
@abc.abstractmethod
@@ -534,7 +536,7 @@ def updated_foo(self):
534536
A.foo = updated_foo
535537
abc.update_abstractmethods(A)
536538
self.assertEqual(A.__abstractmethods__, {'foo', 'bar'})
537-
msg = "class A with abstract methods bar, foo"
539+
msg = "class A without an implementation for abstract methods 'bar', 'foo'"
538540
self.assertRaisesRegex(TypeError, msg, A)
539541

540542
def test_update_implementation(self):
@@ -546,7 +548,7 @@ def foo(self):
546548
class B(A):
547549
pass
548550

549-
msg = "class B with abstract method foo"
551+
msg = "class B without an implementation for abstract method 'foo'"
550552
self.assertRaisesRegex(TypeError, msg, B)
551553
self.assertEqual(B.__abstractmethods__, {'foo'})
552554

@@ -604,7 +606,7 @@ def foo(self):
604606

605607
abc.update_abstractmethods(B)
606608

607-
msg = "class B with abstract method foo"
609+
msg = "class B without an implementation for abstract method 'foo'"
608610
self.assertRaisesRegex(TypeError, msg, B)
609611

610612
def test_update_layered_implementation(self):
@@ -626,7 +628,7 @@ def foo(self):
626628

627629
abc.update_abstractmethods(C)
628630

629-
msg = "class C with abstract method foo"
631+
msg = "class C without an implementation for abstract method 'foo'"
630632
self.assertRaisesRegex(TypeError, msg, C)
631633

632634
def test_update_multi_inheritance(self):

0 commit comments

Comments
 (0)