mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-29 06:09:23 +01:00
Use __import__() instead of exec().
This commit is contained in:
parent
393f78c573
commit
5a35c7fafd
@ -27,6 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ load = unittest.defaultTestLoader.loadTestsFromModule
|
|||||||
|
|
||||||
GLOBALS = globals()
|
GLOBALS = globals()
|
||||||
dirname = os.path.dirname(__file__)
|
dirname = os.path.dirname(__file__)
|
||||||
|
sys.path.append(dirname)
|
||||||
filenames = os.listdir(dirname)
|
filenames = os.listdir(dirname)
|
||||||
# Uncomment these if you need some consistency in the order these tests run.
|
# Uncomment these if you need some consistency in the order these tests run.
|
||||||
# filenames.sort()
|
# filenames.sort()
|
||||||
@ -43,8 +45,8 @@ filenames = os.listdir(dirname)
|
|||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if filename.startswith('test_') and filename.endswith('.py'):
|
if filename.startswith('test_') and filename.endswith('.py'):
|
||||||
name = filename[:-3]
|
name = filename[:-3]
|
||||||
exec 'import %s' % name in GLOBALS
|
plugin = __import__(name)
|
||||||
test.suites.append(load(GLOBALS[name]))
|
test.suites.append(load(plugin))
|
||||||
|
|
||||||
module = None
|
module = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user