MCPcopy Index your code
hub / github.com/python/cpython / validate_abstract_methods

Method validate_abstract_methods

Lib/test/test_collections.py:728–740  ·  view source on GitHub ↗
(self, abc, *names)

Source from the content-addressed store, hash-verified

726class ABCTestCase(unittest.TestCase):
727
728 def validate_abstract_methods(self, abc, *names):
729 methodstubs = dict.fromkeys(names, lambda s, *args: 0)
730
731 # everything should work will all required methods are present
732 C = type('C', (abc,), methodstubs)
733 C()
734
735 # instantiation should fail if a required method is missing
736 for name in names:
737 stubs = methodstubs.copy()
738 del stubs[name]
739 C = type('C', (abc,), stubs)
740 self.assertRaises(TypeError, C)
741
742 def validate_isinstance(self, abc, name):
743 stub = lambda s, *args: 0

Callers 15

test_AwaitableMethod · 0.80
test_CoroutineMethod · 0.80
test_HashableMethod · 0.80
test_AsyncIterableMethod · 0.80
test_AsyncIteratorMethod · 0.80
test_IterableMethod · 0.80
test_ReversibleMethod · 0.80
test_CollectionMethod · 0.80
test_IteratorMethod · 0.80
test_GeneratorMethod · 0.80
test_AsyncGeneratorMethod · 0.80
test_SizedMethod · 0.80

Calls 4

CClass · 0.70
fromkeysMethod · 0.45
copyMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected