summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_scope.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-02-05 17:35:20 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-02-05 17:35:20 (GMT)
commitde6024872abe4fd95972036db63d0a57cf557f94 (patch)
tree4390aab05bcd1462be258ea9cf164f3a0b772cd9 /Lib/test/test_scope.py
parent2524d699f572c5839dcc5c6a7ce06533ac2ef0a6 (diff)
downloadcpython-de6024872abe4fd95972036db63d0a57cf557f94.zip
cpython-de6024872abe4fd95972036db63d0a57cf557f94.tar.gz
cpython-de6024872abe4fd95972036db63d0a57cf557f94.tar.bz2
Fix test 9 (caught by ?!ng)
Add tests for unbound locals (Nick Mathewson)
Diffstat (limited to 'Lib/test/test_scope.py')
-rw-r--r--Lib/test/test_scope.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 8be3f61..57c0dcb 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -154,7 +154,7 @@ class Test:
def str(self):
return str(self)
-t = test()
+t = Test()
verify(t.test() == "var")
verify(t.method_and_var() == "method")
verify(t.actual_global() == "global")
@@ -247,3 +247,32 @@ f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y)
g = f8(1, 2, 3)
h = g(2, 4, 6)
verify(h() == 18)
+
+print "13. UnboundLocal"
+
+def errorInOuter():
+ print y
+ def inner():
+ return y
+ y = 1
+
+def errorInInner():
+ def inner():
+ return y
+ inner()
+ y = 1
+
+try:
+ errorInOuter()
+except UnboundLocalError:
+ pass
+else:
+ raise TestFailed
+
+try:
+ errorInInner()
+except UnboundLocalError:
+ pass
+else:
+ raise TestFailed
+