From 38aca14cc758b556db15408ebf5c9a81cdee7337 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 13 Apr 2011 22:06:49 +0200 Subject: [PATCH] tests for class scope behaviour --- tests/bugs.txt | 2 ++ tests/run/class_scope.py | 14 ++++++++++++++ tests/run/class_scope_T671.py | 12 ++++++++++++ tests/run/class_scope_del_T684.py | 15 +++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tests/run/class_scope.py create mode 100644 tests/run/class_scope_T671.py create mode 100644 tests/run/class_scope_del_T684.py diff --git a/tests/bugs.txt b/tests/bugs.txt index c8845007..7e844b86 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -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 index 00000000..8a3f610d --- /dev/null +++ b/tests/run/class_scope.py @@ -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 index 00000000..a09bc875 --- /dev/null +++ b/tests/run/class_scope_T671.py @@ -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 index 00000000..43368f33 --- /dev/null +++ b/tests/run/class_scope_del_T684.py @@ -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 -- 2.26.2