From 43226004a108fa60bd858a1c6977976a358a4f12 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Mon, 4 Sep 2023 15:42:35 -0700 Subject: [PATCH] ext,tests: Fix `--figures` flag when using `./main.py list` Now the "tests/main.py" script will accept the `--fixtures` flag when using the `list` command. This will only list the fixtures needed. To have this implemented `__str__` for the `Fixture` class has been implemented. Change-Id: I4bba26e923c8b0001163726637f2e48c801e92b1 --- ext/testlib/fixture.py | 4 ++++ ext/testlib/main.py | 2 ++ ext/testlib/query.py | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/ext/testlib/fixture.py b/ext/testlib/fixture.py index 148229a597..0138f018bb 100644 --- a/ext/testlib/fixture.py +++ b/ext/testlib/fixture.py @@ -27,6 +27,7 @@ # Authors: Sean Wilson import testlib.helper as helper +from testlib.configuration import constants class SkipException(Exception): @@ -79,6 +80,9 @@ class Fixture(object): def teardown(self, testitem): pass + def __str__(self): + return f"{self.name} fixture" + def set_global(self): self._is_global = True diff --git a/ext/testlib/main.py b/ext/testlib/main.py index 3888a1ec6b..59ce050bfd 100644 --- a/ext/testlib/main.py +++ b/ext/testlib/main.py @@ -253,6 +253,8 @@ def do_list(): qrunner.list_tests() elif configuration.config.all_tags: qrunner.list_tags() + elif configuration.config.fixtures: + qrunner.list_fixtures() else: qrunner.list_suites() qrunner.list_tests() diff --git a/ext/testlib/query.py b/ext/testlib/query.py index 7b69d7d76b..74541002cd 100644 --- a/ext/testlib/query.py +++ b/ext/testlib/query.py @@ -55,6 +55,13 @@ class QueryRunner(object): for test in suite: log.test_log.message(test.uid, machine_readable=True) + def list_fixtures(self): + log.test_log.message(terminal.separator()) + log.test_log.message('Listing all Test Fixtures.', bold=True) + log.test_log.message(terminal.separator()) + for fixture in self.schedule.all_fixtures(): + log.test_log.message(fixture, machine_readable=True) + def list_suites(self): log.test_log.message(terminal.separator()) log.test_log.message("Listing all Test Suites.", bold=True)