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

Method setUpClass

Lib/test/test_asdl_parser.py:22–35  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

20class TestAsdlParser(unittest.TestCase):
21 @classmethod
22 def setUpClass(cls):
23 # Loads the asdl module dynamically, since it's not in a real importable
24 # package.
25 # Parses Python.asdl into an ast.Module and run the check on it.
26 # There's no need to do this for each test method, hence setUpClass.
27 sys.path.insert(0, parser_dir)
28 loader = importlib.machinery.SourceFileLoader(
29 'asdl', os.path.join(parser_dir, 'asdl.py'))
30 spec = importlib.util.spec_from_loader('asdl', loader)
31 module = importlib.util.module_from_spec(spec)
32 loader.exec_module(module)
33 cls.asdl = module
34 cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl'))
35 cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed')
36
37 @classmethod
38 def tearDownClass(cls):

Callers

nothing calls this directly

Calls 6

assertTrueMethod · 0.80
insertMethod · 0.45
joinMethod · 0.45
exec_moduleMethod · 0.45
parseMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected