提交 feb89827 编写于 作者: C Cleber Rosa

Loader: use the DiscoverMode enum

Avocado 69.0 (LTS) already contains loader.DiscoverMode, so it's safe
to just use it directly here.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 13af3f85
......@@ -34,14 +34,6 @@ from .options import VirtTestOptionsProcess
from .test import VirtTest
if hasattr(loader, "DiscoverMode"):
LOADER_DEFAULT = loader.DiscoverMode.DEFAULT
LOADER_ALL = loader.DiscoverMode.ALL
else:
LOADER_DEFAULT = loader.DEFAULT
LOADER_ALL = loader.ALL
LOG = logging.getLogger("avocado.app")
......@@ -205,12 +197,12 @@ class VirtTestLoader(loader.TestLoader):
@staticmethod
def _report_bad_discovery(name, reason, which_tests):
if which_tests is LOADER_ALL:
if which_tests is loader.DiscoverMode.ALL:
return [(NotAvocadoVTTest, {"name": "%s: %s" % (name, reason)})]
else:
return []
def discover(self, url, which_tests=LOADER_DEFAULT):
def discover(self, url, which_tests=loader.DiscoverMode.DEFAULT):
try:
cartesian_parser = self._get_parser()
except Exception as details:
......@@ -225,7 +217,8 @@ class VirtTestLoader(loader.TestLoader):
# the other test plugins to handle the URL.
except cartesian_config.ParserError as details:
return self._report_bad_discovery(url, details, which_tests)
elif which_tests is LOADER_DEFAULT and not get_opt(self.args, 'vt_config'):
elif (which_tests is loader.DiscoverMode.DEFAULT and
not get_opt(self.args, 'vt_config')):
# By default don't run anything unless vt_config provided
return []
# Create test_suite
......@@ -249,7 +242,7 @@ class VirtTestLoader(loader.TestLoader):
test_parameters = {'name': test_name,
'vt_params': params}
test_suite.append((VirtTest, test_parameters))
if which_tests is LOADER_ALL and not test_suite:
if which_tests is loader.DiscoverMode.ALL and not test_suite:
return self._report_bad_discovery(url, "No matching tests",
which_tests)
return test_suite
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册