def test_test_case_to_ast_twice(simple_test_case): visitor = tc_to_ast.TestCaseToAstVisitor() simple_test_case.accept(visitor) simple_test_case.accept(visitor) assert (astor.to_source(Module(body=visitor.test_case_asts[0])) == "var0 = 5\nvar1 = module0.SomeType(var0)\nassert var1 == 3\n") assert (astor.to_source(Module(body=visitor.test_case_asts[1])) == "var0 = 5\nvar1 = module0.SomeType(var0)\nassert var1 == 3\n")
def test_test_case_to_ast_module_aliases(simple_test_case): visitor = tc_to_ast.TestCaseToAstVisitor() simple_test_case.accept(visitor) simple_test_case.accept(visitor) assert ("tests.fixtures.accessibles.accessible" in visitor.module_aliases.known_name_indices) assert (visitor.module_aliases.get_name( "tests.fixtures.accessibles.accessible") == "module0")
def _transform_to_asts( self, test_cases: List[tc.TestCase], ) -> Tuple[List[List[ast.stmt]], NamingScope]: visitor = tc_to_ast.TestCaseToAstVisitor(wrap_code=self._wrap_code) for test_case in test_cases: test_case.accept(visitor) return visitor.test_case_asts, visitor.module_aliases