Skip to content

Commit e0f03e3

Browse files
committed
Test updates from review
1 parent faaa19a commit e0f03e3

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Lib/test/test_ast/test_ast.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ def test_dynamic_attr(self):
428428
# Custom attribute assignment is allowed
429429
x.foo = 5
430430
self.assertEqual(x.foo, 5)
431-
del x.foo
432431

433432
def _construct_ast_class(self, cls):
434433
kwargs = {}
@@ -471,9 +470,6 @@ def test_field_attr_writable(self):
471470
self.assertEqual(x._fields, 666)
472471

473472
def test_classattrs(self):
474-
msg = "ast.Constant.__init__ missing 1 required positional argument: 'value'"
475-
self.assertRaisesRegex(TypeError, re.escape(msg), ast.Constant)
476-
477473
x = ast.Constant(42)
478474
self.assertEqual(x._fields, ('value', 'kind'))
479475

@@ -496,11 +492,6 @@ def test_classattrs(self):
496492
self.assertRaises(TypeError, ast.Constant, 1, None, 2)
497493
self.assertRaises(TypeError, ast.Constant, 1, None, 2, lineno=0)
498494

499-
# Arbitrary keyword arguments are not supported
500-
msg = "ast.Constant.__init__ got an unexpected keyword argument 'foo'"
501-
with self.assertRaisesRegex(TypeError, re.escape(msg)):
502-
ast.Constant(1, foo='bar')
503-
504495
msg = "ast.Constant got multiple values for argument 'value'"
505496
with self.assertRaisesRegex(TypeError, re.escape(msg)):
506497
ast.Constant(1, value=2)
@@ -554,7 +545,7 @@ def test_nodeclasses(self):
554545
self.assertEqual(x.op, addop)
555546
self.assertEqual(x.right, n3)
556547

557-
# Random attribute allowed too
548+
# Arbitrary attributes are allowed
558549
x.foobarbaz = 5
559550
self.assertEqual(x.foobarbaz, 5)
560551
self.assertEqual(x._fields, ('left', 'op', 'right'))
@@ -582,7 +573,7 @@ def test_nodeclasses(self):
582573
self.assertEqual(x.right, 3)
583574
self.assertEqual(x.lineno, 0)
584575

585-
# Random kwargs are not allowed
576+
# Arbitrary keyword arguments are not allowed
586577
msg = "ast.BinOp.__init__ got an unexpected keyword argument 'foobarbaz'"
587578
with self.assertRaisesRegex(TypeError, re.escape(msg)):
588579
ast.BinOp(1, 2, 3, foobarbaz=42)

0 commit comments

Comments
 (0)