-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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.
cpython/Lib/test/test_collections.py
Lines 727 to 739 in 481d5b5
| 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
- gh-137463: Update
validate_abstract_methodsintest_collections.py#137464 - [3.14] gh-137463: Update
validate_abstract_methodsintest_collections.py(GH-137464) #137503 - [3.13] gh-137463: Update validate_abstract_methods in test_collections.py (GH-137464) #137516
- [3.13] gh-137463: Update validate_abstract_methods in test_collections.py (GH-137464) #137521
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error