MCPcopy Index your code
hub / github.com/python/cpython / setUpModule

Function setUpModule

Lib/test/test_xml_etree.py:4813–4847  ·  view source on GitHub ↗
(module=None)

Source from the content-addressed store, hash-verified

4811# --------------------------------------------------------------------
4812
4813def 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
4850if __name__ == '__main__':

Callers

nothing calls this directly

Calls 2

import_fresh_moduleFunction · 0.90
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…