tests for class scope behaviour
authorStefan Behnel <scoder@users.berlios.de>
Wed, 13 Apr 2011 20:06:49 +0000 (22:06 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 13 Apr 2011 20:06:49 +0000 (22:06 +0200)
tests/bugs.txt
tests/run/class_scope.py [new file with mode: 0644]
tests/run/class_scope_T671.py [new file with mode: 0644]
tests/run/class_scope_del_T684.py [new file with mode: 0644]

index c8845007f082d382ac7a4097db9fa98368710d98..7e844b860364193d757969d69c3c0856335c413d 100644 (file)
@@ -18,6 +18,8 @@ genexpr_iterable_lookup_T600
 for_from_pyvar_loop_T601
 decorators_T593
 temp_sideeffects_T654
+class_scope_T671
+class_scope_del_T684
 
 # CPython regression tests that don't current work:
 pyregr.test_threadsignals
diff --git a/tests/run/class_scope.py b/tests/run/class_scope.py
new file mode 100644 (file)
index 0000000..8a3f610
--- /dev/null
@@ -0,0 +1,14 @@
+# mode:run
+# tag: class, scope
+
+class MethodRedef(object):
+    """
+    >>> MethodRedef().a(5)
+    7
+    """
+
+    def a(self, i):
+        return i+1
+
+    def a(self, i):
+        return i+2
diff --git a/tests/run/class_scope_T671.py b/tests/run/class_scope_T671.py
new file mode 100644 (file)
index 0000000..a09bc87
--- /dev/null
@@ -0,0 +1,12 @@
+# mode:run
+# tag: class, scope
+# ticket: 671
+
+MAIN = True
+
+class OuterScopeLookup(object):
+    """
+    >>> OuterScopeLookup.MAIN
+    True
+    """
+    MAIN = MAIN  # looked up in parent scope, assigned to class scope
diff --git a/tests/run/class_scope_del_T684.py b/tests/run/class_scope_del_T684.py
new file mode 100644 (file)
index 0000000..43368f3
--- /dev/null
@@ -0,0 +1,15 @@
+# mode:run
+# tag: class, scope, del
+# ticket: 684
+
+class DelInClass(object):
+    """
+    >>> DelInClass.y
+    5
+    >>> DelInClass.x
+    Traceback (most recent call last):
+    AttributeError: type object 'DelInClass' has no attribute 'x'
+    """
+    x = 5
+    y = x
+    del x