From b2f19b8d349314baba640e1dd99ea833d0bc4b8f Mon Sep 17 00:00:00 2001 From: Damien George <damien.p.george@gmail.com> Date: Sun, 26 Oct 2014 15:38:28 +0000 Subject: [PATCH] tests: Get builtin_compile to skin properly on pyboard. --- tests/basics/builtin_compile.py | 36 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/basics/builtin_compile.py b/tests/basics/builtin_compile.py index b6f65a2fa..ef3ff014d 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") -- GitLab