mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
convert old fail* assertions to assert*
This commit is contained in:
parent
98d23f2e06
commit
c9c0f201fe
275 changed files with 4540 additions and 4540 deletions
|
@ -116,20 +116,20 @@ eval_tests = [
|
|||
|
||||
class AST_Tests(unittest.TestCase):
|
||||
|
||||
def _assert_order(self, ast_node, parent_pos):
|
||||
def _assertTrueorder(self, ast_node, parent_pos):
|
||||
if not isinstance(ast_node, ast.AST) or ast_node._fields is None:
|
||||
return
|
||||
if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)):
|
||||
node_pos = (ast_node.lineno, ast_node.col_offset)
|
||||
self.assert_(node_pos >= parent_pos)
|
||||
self.assertTrue(node_pos >= parent_pos)
|
||||
parent_pos = (ast_node.lineno, ast_node.col_offset)
|
||||
for name in ast_node._fields:
|
||||
value = getattr(ast_node, name)
|
||||
if isinstance(value, list):
|
||||
for child in value:
|
||||
self._assert_order(child, parent_pos)
|
||||
self._assertTrueorder(child, parent_pos)
|
||||
elif value is not None:
|
||||
self._assert_order(value, parent_pos)
|
||||
self._assertTrueorder(value, parent_pos)
|
||||
|
||||
def test_snippets(self):
|
||||
for input, output, kind in ((exec_tests, exec_results, "exec"),
|
||||
|
@ -138,7 +138,7 @@ class AST_Tests(unittest.TestCase):
|
|||
for i, o in zip(input, output):
|
||||
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
|
||||
self.assertEquals(to_tuple(ast_tree), o)
|
||||
self._assert_order(ast_tree, (0, 0))
|
||||
self._assertTrueorder(ast_tree, (0, 0))
|
||||
|
||||
def test_slice(self):
|
||||
slc = ast.parse("x[::]").body[0].value.slice
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue