diff --git a/tobiko/common/_testcase.py b/tobiko/common/_testcase.py index 341ee8f51..3d75069c9 100644 --- a/tobiko/common/_testcase.py +++ b/tobiko/common/_testcase.py @@ -20,7 +20,6 @@ import traceback import typing # noqa from oslo_log import log -from stestr import config_file import testtools from tobiko.common import _config @@ -85,6 +84,8 @@ class TestCasesFinder(object): filter the output just like with the run command to see exactly what will be run. """ + from stestr import config_file + params = dict(config=self.config, repo_type=self.repo_type, repo_url=self.repo_url, test_path=self.test_path, top_dir=self.top_dir, group_regex=self.group_regex, diff --git a/tobiko/tests/unit/cmd/__init__.py b/tobiko/tests/unit/commands/__init__.py similarity index 100% rename from tobiko/tests/unit/cmd/__init__.py rename to tobiko/tests/unit/commands/__init__.py diff --git a/tobiko/tests/unit/cmd/test_base.py b/tobiko/tests/unit/commands/test_base.py similarity index 100% rename from tobiko/tests/unit/cmd/test_base.py rename to tobiko/tests/unit/commands/test_base.py diff --git a/tobiko/tests/unit/cmd/test_fixture.py b/tobiko/tests/unit/commands/test_fixture.py similarity index 100% rename from tobiko/tests/unit/cmd/test_fixture.py rename to tobiko/tests/unit/commands/test_fixture.py diff --git a/tobiko/tests/unit/test_testcase.py b/tobiko/tests/unit/test_testcase.py index c287ceb5d..70a50a3a0 100644 --- a/tobiko/tests/unit/test_testcase.py +++ b/tobiko/tests/unit/test_testcase.py @@ -14,6 +14,7 @@ from __future__ import absolute_import import os +import subprocess import testtools @@ -30,11 +31,15 @@ class DiscoverTestCasesTest(unit.TobikoUnitTest): top_dir = os.path.abspath(self.test_path) while os.path.isdir(top_dir) and top_dir != os.path.sep: - if os.path.isdir(os.path.join(top_dir, '.stestr')): + if os.path.isfile(os.path.join(top_dir, 'tox.ini')): break top_dir = os.path.dirname(top_dir) else: - raise self.fail("Unable to find '.stestr' directory") + self.fail("'tox.ini' file not found in any parent " + f"of directory '{self.test_path}'") + + if not os.path.isdir(os.path.join(top_dir, '.stestr')): + subprocess.run(['stestr', 'init'], cwd=top_dir, check=True) self.top_dir = top_dir self.repo_url = top_dir