MCPcopy Create free account
hub / github.com/NVIDIA/DALI / assertAstMatches

Method assertAstMatches

dali/test/python/autograph/pyct/test_parser.py:31–42  ·  view source on GitHub ↗
(self, actual_node, expected_node_src, expr=True)

Source from the content-addressed store, hash-verified

29
30class ParserTest(unittest.TestCase):
31 def assertAstMatches(self, actual_node, expected_node_src, expr=True):
32 if expr:
33 # Ensure multi-line expressions parse.
34 expected_node = gast.parse("({})".format(expected_node_src)).body[0]
35 expected_node = expected_node.value
36 else:
37 expected_node = gast.parse(expected_node_src).body[0]
38
39 msg = "AST did not match expected:\n{}\nActual:\n{}".format(
40 pretty_printer.fmt(expected_node), pretty_printer.fmt(actual_node)
41 )
42 self.assertTrue(ast_util.matches(actual_node, expected_node), msg)
43
44 def test_parse_entity(self):
45 def f(x):

Calls 2

parseMethod · 0.45
matchesMethod · 0.45

Tested by

no test coverage detected