(module=None)
| 4811 | # -------------------------------------------------------------------- |
| 4812 | |
| 4813 | def setUpModule(module=None): |
| 4814 | # When invoked without a module, runs the Python ET tests by loading pyET. |
| 4815 | # Otherwise, uses the given module as the ET. |
| 4816 | global pyET |
| 4817 | pyET = import_fresh_module('xml.etree.ElementTree', |
| 4818 | blocked=['_elementtree']) |
| 4819 | if module is None: |
| 4820 | module = pyET |
| 4821 | |
| 4822 | global ET |
| 4823 | ET = module |
| 4824 | |
| 4825 | # don't interfere with subsequent tests |
| 4826 | def cleanup(): |
| 4827 | global ET, pyET |
| 4828 | ET = pyET = None |
| 4829 | unittest.addModuleCleanup(cleanup) |
| 4830 | |
| 4831 | # Provide default namespace mapping and path cache. |
| 4832 | from xml.etree import ElementPath |
| 4833 | nsmap = ET.register_namespace._namespace_map |
| 4834 | # Copy the default namespace mapping |
| 4835 | nsmap_copy = nsmap.copy() |
| 4836 | unittest.addModuleCleanup(nsmap.update, nsmap_copy) |
| 4837 | unittest.addModuleCleanup(nsmap.clear) |
| 4838 | |
| 4839 | # Copy the path cache (should be empty) |
| 4840 | path_cache = ElementPath._cache |
| 4841 | unittest.addModuleCleanup(setattr, ElementPath, "_cache", path_cache) |
| 4842 | ElementPath._cache = path_cache.copy() |
| 4843 | |
| 4844 | # Align the Comment/PI factories. |
| 4845 | if hasattr(ET, '_set_factories'): |
| 4846 | old_factories = ET._set_factories(ET.Comment, ET.PI) |
| 4847 | unittest.addModuleCleanup(ET._set_factories, *old_factories) |
| 4848 | |
| 4849 | |
| 4850 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected
searching dependent graphs…