summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_named_expressions.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_named_expressions.py b/Lib/test/test_named_expressions.py
index c813830..d614f32 100644
--- a/Lib/test/test_named_expressions.py
+++ b/Lib/test/test_named_expressions.py
@@ -513,6 +513,15 @@ spam()"""
self.assertEqual(nonlocal_var, None)
f()
+ def test_named_expression_scope_in_genexp(self):
+ a = 1
+ b = [1, 2, 3, 4]
+ genexp = (c := i + a for i in b)
+
+ self.assertNotIn("c", locals())
+ for idx, elem in enumerate(genexp):
+ self.assertEqual(elem, b[idx] + a)
+
if __name__ == "__main__":
unittest.main()