Skip to content

Commit 86fc270

Browse files
committed
add unittest to test for custom list subclassing with list.__init__ call
1 parent cadf050 commit 86fc270

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,19 @@ def __iter__(self):
6262

6363
l = list(ListSubclass([1, 2, 3, 4]))
6464
assert l == [10, 20, 30, 40], "was: {!s}".format(l)
65+
66+
67+
def test_list_init_call():
68+
class MyList(list):
69+
def __init__(self, a, b=None):
70+
if b:
71+
list.__init__(self, [b])
72+
else:
73+
list.__init__(self, [a])
74+
75+
l = MyList(10)
76+
assert l == [10]
77+
l = MyList(10, 20)
78+
assert l == [20]
79+
l = MyList(10, b=30)
80+
assert l == [30]

0 commit comments

Comments
 (0)