MCPcopy Create free account
hub / github.com/python/cpython / _assertTrueorder

Method _assertTrueorder

Lib/test/test_ast/test_ast.py:68–85  ·  view source on GitHub ↗
(self, ast_node, parent_pos)

Source from the content-addressed store, hash-verified

66 return name != 'AST' and name[0].isupper()
67
68 def _assertTrueorder(self, ast_node, parent_pos):
69 if not isinstance(ast_node, ast.AST) or ast_node._fields is None:
70 return
71 if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)):
72 node_pos = (ast_node.lineno, ast_node.col_offset)
73 self.assertGreaterEqual(node_pos, parent_pos)
74 parent_pos = (ast_node.lineno, ast_node.col_offset)
75 for name in ast_node._fields:
76 value = getattr(ast_node, name)
77 if isinstance(value, list):
78 first_pos = parent_pos
79 if value and name == 'decorator_list':
80 first_pos = (value[0].lineno, value[0].col_offset)
81 for child in value:
82 self._assertTrueorder(child, first_pos)
83 elif value is not None:
84 self._assertTrueorder(value, parent_pos)
85 self.assertEqual(ast_node._fields, ast_node.__match_args__)
86
87 def test_AST_objects(self):
88 x = ast.AST()

Callers 1

test_snippetsMethod · 0.95

Calls 2

assertGreaterEqualMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected