Skip to content

Commit adcb877

Browse files
sbinetncw
authored andcommitted
builtin,vm: fix builtin-isinstance test
1 parent f446791 commit adcb877

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

builtin/tests/builtin.py

+9
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ def func(p):
167167
assertRaises(TypeError, hex, 10.0) ## TypeError: 'float' object cannot be interpreted as an integer
168168
assertRaises(TypeError, hex, float(0)) ## TypeError: 'float' object cannot be interpreted as an integer
169169

170+
doc="isinstance"
171+
class A:
172+
pass
173+
a = A()
174+
assert isinstance(1, (str, tuple, int))
175+
assert isinstance(a, (str, (tuple, (A, ))))
176+
assertRaises(TypeError, isinstance, 1, (A, ), "foo")
177+
assertRaises(TypeError, isinstance, 1, [A, "foo"])
178+
170179
doc="iter"
171180
cnt = 0
172181
def f():

vm/tests/builtin.py

-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2018 The go-python Authors. All rights reserved.
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
4-
from libtest import assertRaises
54

65
doc="eval"
76
assert eval("1+2") == 3
@@ -66,13 +65,4 @@
6665
else:
6766
assert False, "SyntaxError not raised"
6867

69-
doc="isinstance"
70-
class A:
71-
pass
72-
a = A()
73-
assert True, isinstance(1, (str, tuple, int))
74-
assert True, isinstance(a, (str, (tuple, (A, ))))
75-
assertRaises(TypeError, isinstance, 1, (A, ), "foo")
76-
assertRaises(TypeError, isinstance, 1, [A, "foo"])
77-
7868
doc="finished"

0 commit comments

Comments
 (0)