MCPcopy Index your code
hub / github.com/RustPython/RustPython / validate_abstract_methods

Method validate_abstract_methods

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

Source from the content-addressed store, hash-verified

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