diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-04 10:04:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 10:04:32 (GMT) |
commit | 074ac1f72e392a576516639f650bac0519d1cb52 (patch) | |
tree | f556839b383ddee0486ce55956eb2a6d1fa7de45 /Lib/test/test_xml_etree_c.py | |
parent | d0b22f6bd84239e50b43709f98f2bb950222cfe5 (diff) | |
download | cpython-074ac1f72e392a576516639f650bac0519d1cb52.zip cpython-074ac1f72e392a576516639f650bac0519d1cb52.tar.gz cpython-074ac1f72e392a576516639f650bac0519d1cb52.tar.bz2 |
bpo-45229: Make ElementTree tests discoverable (GH-108859)
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r-- | Lib/test/test_xml_etree_c.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index fd27b57..3a0fc57 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -254,20 +254,25 @@ class SizeofTest(unittest.TestCase): self.check_sizeof(e, self.elementsize + self.extra + struct.calcsize('8P')) -def test_main(): - from test import test_xml_etree - - # Run the tests specific to the C implementation - support.run_unittest( - MiscTests, - TestAliasWorking, - TestAcceleratorImported, - SizeofTest, - ) - # Run the same test suite as the Python module - test_xml_etree.test_main(module=cET) +def install_tests(): + # Test classes should have __module__ referring to this module. + from test import test_xml_etree + for name, base in vars(test_xml_etree).items(): + if isinstance(base, type) and issubclass(base, unittest.TestCase): + class Temp(base): + pass + Temp.__name__ = Temp.__qualname__ = name + Temp.__module__ = __name__ + assert name not in globals() + globals()[name] = Temp + +install_tests() + +def setUpModule(): + from test import test_xml_etree + test_xml_etree.setUpModule(module=cET) if __name__ == '__main__': - test_main() + unittest.main() |