Skip to content

Commit b2f19b8

Browse files
committed
tests: Get builtin_compile to skin properly on pyboard.
1 parent 480a7ce commit b2f19b8

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

tests/basics/builtin_compile.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# test compile builtin
22

3-
try:
4-
compile
5-
except NameError:
6-
print("SKIP")
7-
import sys
8-
sys.exit()
3+
def have_compile():
4+
try:
5+
compile
6+
return True
7+
except NameError:
8+
return False
9+
10+
# global variable for compiled code to access
11+
x = 1
912

10-
c = compile("print(x)", "file", "exec")
13+
def test():
14+
c = compile("print(x)", "file", "exec")
15+
16+
try:
17+
exec(c)
18+
except NameError:
19+
print("NameError")
1120

12-
try:
1321
exec(c)
14-
except NameError:
15-
print("NameError")
1622

17-
x = 1
18-
exec(c)
23+
exec(c, {"x":2})
24+
exec(c, {}, {"x":3})
1925

20-
exec(c, {"x":2})
21-
exec(c, {}, {"x":3})
26+
if have_compile():
27+
test()
28+
else:
29+
print("SKIP")

0 commit comments

Comments
 (0)