(self)
| 601 | self.assertIsInstance(ast_module, ast.Module) |
| 602 | |
| 603 | def test_bindings_module(self): |
| 604 | generator = PythonGenerator(self.col_xsd_file) |
| 605 | |
| 606 | python_module = generator.render('bindings.py.jinja')[0] |
| 607 | |
| 608 | ast_module = ast.parse(python_module) |
| 609 | self.assertIsInstance(ast_module, ast.Module) |
| 610 | |
| 611 | collection_dir = Path(__file__).parent.joinpath('test_cases/examples/collection') |
| 612 | cwd = os.getcwd() |
| 613 | try: |
| 614 | os.chdir(str(collection_dir)) |
| 615 | with open('collection.py', 'w') as fp: |
| 616 | fp.write(python_module) |
| 617 | |
| 618 | spec = importlib.util.spec_from_file_location('collection', 'collection.py') |
| 619 | module = importlib.util.module_from_spec(spec) |
| 620 | spec.loader.exec_module(module) |
| 621 | except SyntaxError: |
| 622 | pass |
| 623 | else: |
| 624 | col_data = module.CollectionBinding.fromsource('collection.xml') |
| 625 | col_root = ElementTree.XML(col_data.tostring()) |
| 626 | self.assertEqual(col_root.tag, '{http://example.com/ns/collection}collection') |
| 627 | finally: |
| 628 | os.chdir(cwd) |
| 629 | |
| 630 | |
| 631 | @unittest.skipIf(jinja2 is None, "jinja2 library is not installed!") |
nothing calls this directly
no test coverage detected