Skip to content

Commit cec4fa5

Browse files
committed
add test for class body scope
1 parent 5796ee7 commit cec4fa5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_scope.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,3 +906,29 @@ def my_obj():
906906

907907
assert set(my_obj.__code__.co_cellvars) == set()
908908
assert set(my_obj.__code__.co_freevars) == {'my_obj', 'y'}
909+
910+
911+
def test_classbody_scope():
912+
class A():
913+
ranges = [(1, 10)]
914+
915+
class B():
916+
ranges = [(2, 12)]
917+
918+
class C():
919+
ranges = [ ]
920+
921+
class CA():
922+
ranges = [(3, 13)]
923+
924+
locs = locals()
925+
926+
class D(B, C):
927+
pass
928+
929+
930+
A.C.ranges = (A.C.CA.ranges)
931+
assert A.C.ranges == A.C.CA.ranges == [(3, 13)]
932+
locs = list(A.locs.keys())
933+
for k in ["__module__", "__qualname__", "ranges", "B", "C", "locs", "D"]:
934+
assert k in locs, locs

0 commit comments

Comments
 (0)