From 5a35c7fafd6cc4d02b585fcd6f3f2304de4d2d3e Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 5 Aug 2012 10:22:15 +0200 Subject: [PATCH] Use __import__() instead of exec(). --- test/test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test.py b/test/test.py index b8c8ae962..33541326c 100644 --- a/test/test.py +++ b/test/test.py @@ -27,6 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### +import sys import os.path import unittest @@ -36,6 +37,7 @@ load = unittest.defaultTestLoader.loadTestsFromModule GLOBALS = globals() dirname = os.path.dirname(__file__) +sys.path.append(dirname) filenames = os.listdir(dirname) # Uncomment these if you need some consistency in the order these tests run. # filenames.sort() @@ -43,8 +45,8 @@ filenames = os.listdir(dirname) for filename in filenames: if filename.startswith('test_') and filename.endswith('.py'): name = filename[:-3] - exec 'import %s' % name in GLOBALS - test.suites.append(load(GLOBALS[name])) + plugin = __import__(name) + test.suites.append(load(plugin)) module = None