summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBatuhan Taşkaya <47358913+isidentical@users.noreply.github.com>2020-03-16 08:12:53 (GMT)
committerGitHub <noreply@github.com>2020-03-16 08:12:53 (GMT)
commit4ab362cec6dc68c798b3e354f687cf39e207b9a9 (patch)
treefd3e04e72101bda5ade2fc0ee4437974a53daa9b /Lib
parent5b66ec166b81c8a77286da2c0d17be3579c3069a (diff)
downloadcpython-4ab362cec6dc68c798b3e354f687cf39e207b9a9.zip
cpython-4ab362cec6dc68c798b3e354f687cf39e207b9a9.tar.gz
cpython-4ab362cec6dc68c798b3e354f687cf39e207b9a9.tar.bz2
bpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_asdl_parser.py8
-rw-r--r--Lib/test/test_ast.py10
2 files changed, 14 insertions, 4 deletions
diff --git a/Lib/test/test_asdl_parser.py b/Lib/test/test_asdl_parser.py
index d3306c2..2c14817 100644
--- a/Lib/test/test_asdl_parser.py
+++ b/Lib/test/test_asdl_parser.py
@@ -63,10 +63,10 @@ class TestAsdlParser(unittest.TestCase):
def test_attributes(self):
stmt = self.types['stmt']
self.assertEqual(len(stmt.attributes), 4)
- self.assertEqual(str(stmt.attributes[0]), 'Field(int, lineno)')
- self.assertEqual(str(stmt.attributes[1]), 'Field(int, col_offset)')
- self.assertEqual(str(stmt.attributes[2]), 'Field(int, end_lineno, opt=True)')
- self.assertEqual(str(stmt.attributes[3]), 'Field(int, end_col_offset, opt=True)')
+ self.assertEqual(repr(stmt.attributes[0]), 'Field(int, lineno)')
+ self.assertEqual(repr(stmt.attributes[1]), 'Field(int, col_offset)')
+ self.assertEqual(repr(stmt.attributes[2]), 'Field(int, end_lineno, opt=True)')
+ self.assertEqual(repr(stmt.attributes[3]), 'Field(int, end_col_offset, opt=True)')
def test_constructor_fields(self):
ehandler = self.types['excepthandler']
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 0058e93..66f8384 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -636,6 +636,16 @@ class AST_Tests(unittest.TestCase):
attr_b = tree.body[0].decorator_list[0].value
self.assertEqual(attr_b.end_col_offset, 4)
+ def test_ast_asdl_signature(self):
+ self.assertEqual(ast.withitem.__doc__, "withitem(expr context_expr, expr? optional_vars)")
+ self.assertEqual(ast.GtE.__doc__, "GtE")
+ self.assertEqual(ast.Name.__doc__, "Name(identifier id, expr_context ctx)")
+ self.assertEqual(ast.cmpop.__doc__, "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn")
+ expressions = [f" | {node.__doc__}" for node in ast.expr.__subclasses__()]
+ expressions[0] = f"expr = {ast.expr.__subclasses__()[0].__doc__}"
+ self.assertCountEqual(ast.expr.__doc__.split("\n"), expressions)
+
+
class ASTHelpers_Test(unittest.TestCase):
maxDiff = None