From f9ab38c898ef6dc76c4c69161d6040dc1e26996c Mon Sep 17 00:00:00 2001 From: madsmpedersen <m@madsp.dk> Date: Tue, 22 Dec 2015 07:26:16 +0100 Subject: [PATCH] call testsuite from any working directory --- tests/testsuite.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testsuite.py b/tests/testsuite.py index d4578071..ae82dffe 100644 --- a/tests/testsuite.py +++ b/tests/testsuite.py @@ -1,15 +1,15 @@ import glob import unittest import os - +from os.path import dirname, relpath, abspath def module_strings(): - test_file_paths = glob.glob('test_*.py') + test_file_paths = [] #test_file_strings.extend(glob.glob('../wetb/**/test_*.py')) #for root,_,_ in os.walk("../wetb/"): - for folder, _, _ in os.walk(os.path.join(os.path.dirname(__file__), '../wetb')): - test_file_paths.extend(glob.glob(os.path.join(folder, "tests/test_*.py"))) - return [s[3:len(s) - 3].replace(os.path.sep, ".") for s in test_file_paths] + for folder, _, _ in os.walk(os.path.abspath(dirname(__file__) + '/../wetb/')): + test_file_paths.extend(glob.glob(folder + "/tests/test_*.py")) + return [relpath(s, abspath(dirname(__file__) + "/../")).replace(".py", "").replace(os.path.sep, ".") for s in test_file_paths] def suite(): @@ -60,4 +60,4 @@ else: for mstr in module_strings(): print (mstr) __import__(mstr, {}, {}, "*") - exec("from %s import *" % mstr) \ No newline at end of file + exec("from %s import *" % mstr) -- GitLab