We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85986cd commit 309bc4eCopy full SHA for 309bc4e
Lib/test/test_ast/test_ast.py
@@ -417,6 +417,18 @@ def test_field_attr_existence(self):
417
if isinstance(x, ast.AST):
418
self.assertIs(type(x._fields), tuple)
419
420
+ def test_dynamic_attr(self):
421
+ for name, item in ast.__dict__.items():
422
+ # constructor has a different signature
423
+ if name == 'Index':
424
+ continue
425
+ if self._is_ast_node(name, item):
426
+ x = self._construct_ast_class(item)
427
+ # Random attribute assignment is allowed
428
+ x.foo = 5
429
+ self.assertEqual(x.foo, 5)
430
+ del x.foo
431
+
432
def _construct_ast_class(self, cls):
433
kwargs = {}
434
for name, typ in cls.__annotations__.items():
0 commit comments