Provide a full path top level to test discovery

OS_TOP_LEVEL environment variable allows for the tempest code
to be in a different tree compared to .testr.conf.
However test_discover does not work because relative path is
passed in as top level. Fixing that.

Change-Id: Ieee0704c4895381bc64234bb18e720df67187aad
This commit is contained in:
Andrea Frittoli (andreaf) 2015-06-26 16:29:29 +01:00
parent 91ebdfac2f
commit d30fe3b8b9
1 changed files with 6 additions and 4 deletions

View File

@ -30,12 +30,14 @@ def load_tests(loader, tests, pattern):
base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
base_path = os.path.split(base_path)[0]
# Load local tempest tests
for test_dir in ['./tempest/api', './tempest/scenario',
'./tempest/thirdparty']:
for test_dir in ['tempest/api', 'tempest/scenario',
'tempest/thirdparty']:
full_test_dir = os.path.join(base_path, test_dir)
if not pattern:
suite.addTests(loader.discover(test_dir, top_level_dir=base_path))
suite.addTests(loader.discover(full_test_dir,
top_level_dir=base_path))
else:
suite.addTests(loader.discover(test_dir, pattern=pattern,
suite.addTests(loader.discover(full_test_dir, pattern=pattern,
top_level_dir=base_path))
plugin_load_tests = ext_plugins.get_plugin_load_tests_tuple()