(cls)
| 20 | class 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): |
nothing calls this directly
no test coverage detected