From b2f19b8d349314baba640e1dd99ea833d0bc4b8f Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 26 Oct 2014 15:38:28 +0000 Subject: tests: Get builtin_compile to skin properly on pyboard. --- tests/basics/builtin_compile.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'tests/basics/builtin_compile.py') diff --git a/tests/basics/builtin_compile.py b/tests/basics/builtin_compile.py index b6f65a2fa3..ef3ff014d4 100644 --- a/tests/basics/builtin_compile.py +++ b/tests/basics/builtin_compile.py @@ -1,21 +1,29 @@ # test compile builtin -try: - compile -except NameError: - print("SKIP") - import sys - sys.exit() +def have_compile(): + try: + compile + return True + except NameError: + return False + +# global variable for compiled code to access +x = 1 -c = compile("print(x)", "file", "exec") +def test(): + c = compile("print(x)", "file", "exec") + + try: + exec(c) + except NameError: + print("NameError") -try: exec(c) -except NameError: - print("NameError") -x = 1 -exec(c) + exec(c, {"x":2}) + exec(c, {}, {"x":3}) -exec(c, {"x":2}) -exec(c, {}, {"x":3}) +if have_compile(): + test() +else: + print("SKIP") -- cgit v1.2.3