From 35b11d4c84febbc1e86cb552546c838424b18142 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 11 Nov 2008 22:39:17 +0100 Subject: [PATCH] extended test case --- tests/run/exectest.pyx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/run/exectest.pyx b/tests/run/exectest.pyx index 8e607d9b..11b36fbd 100644 --- a/tests/run/exectest.pyx +++ b/tests/run/exectest.pyx @@ -1,5 +1,7 @@ __doc__ = """# no unicode string, not tested in Python3! #>>> a +#Traceback (most recent call last): +#NameError: name 'a' is not defined #>>> test_module_scope() #>>> a @@ -35,10 +37,21 @@ None 16 >>> test_dict_scope_ref(d, d) >>> print d['b'] 16 + +>>> d = dict(seq = [1,2,3,4]) +>>> add_iter = test_def(d, 'seq') +>>> list(add_iter()) +[2, 3, 4, 5] + +>>> # errors + +>>> d1, d2 = {}, {} +>>> test_dict_scope_ref(d1, d2) +Traceback (most recent call last): +NameError: name 'a' is not defined """ #def test_module_scope(): -# global a # exec "a=1+1" # return __dict__['a'] @@ -55,3 +68,11 @@ def test_dict_scope3(d1, d2): def test_dict_scope_ref(d1, d2): exec "b=a+c" in d1, d2 + +def test_def(d, varref): + exec """ +def test(): + for x in %s: + yield x+1 +""" % varref in d + return d['test'] -- 2.26.2