Bug report
Bug description:
The test for missing abstract methods in validate_abstract_methods incorrectly attempted to instantiate the generated class C with an argument (C(name)), which always raises a TypeError: C() takes no arguments. Although the test originally passes, it passes for the wrong reason.
|
def validate_abstract_methods(self, abc, *names): |
|
methodstubs = dict.fromkeys(names, lambda s, *args: 0) |
|
|
|
# everything should work will all required methods are present |
|
C = type('C', (abc,), methodstubs) |
|
C() |
|
|
|
# instantiation should fail if a required method is missing |
|
for name in names: |
|
stubs = methodstubs.copy() |
|
del stubs[name] |
|
C = type('C', (abc,), stubs) |
|
self.assertRaises(TypeError, C, name) |
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
The test for missing abstract methods in
validate_abstract_methodsincorrectly attempted to instantiate the generated classCwith an argument (C(name)), which always raises aTypeError: C() takes no arguments. Although the test originally passes, it passes for the wrong reason.cpython/Lib/test/test_collections.py
Lines 727 to 739 in 481d5b5
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
validate_abstract_methodsintest_collections.py#137464validate_abstract_methodsintest_collections.py(GH-137464) #137503