From f380289a842370ce650ce79f1678d81a199c562f Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 7 Nov 2024 10:36:11 +0100 Subject: [PATCH] fixup test for cfg_editor utils to run from non-checkout, and fix names, and remove example code Change-Id: I6224244392e2a2d0928065ba24abcbe822096084 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34934 Tested-by: Jenkins Automated Tests Reviewed-by: Alexander Zaft --- frappy/gui/cfg_editor/utils.py | 6 ++++-- test/conftest.py | 17 ----------------- test/test_cfg_editor.py | 13 +++++++++++++ test/test_test.py | 14 -------------- 4 files changed, 17 insertions(+), 33 deletions(-) create mode 100644 test/test_cfg_editor.py delete mode 100644 test/test_test.py diff --git a/frappy/gui/cfg_editor/utils.py b/frappy/gui/cfg_editor/utils.py index 2e6b03a..b9f7c21 100644 --- a/frappy/gui/cfg_editor/utils.py +++ b/frappy/gui/cfg_editor/utils.py @@ -106,7 +106,8 @@ def get_file_paths(widget, open_file=True): def get_modules(): modules = {} - generalConfig.init() + if not generalConfig.initialized: + generalConfig.init() base_path = generalConfig.basedir # pylint: disable=too-many-nested-blocks for dirname in listdir(base_path): @@ -157,7 +158,8 @@ def get_interface_class_from_name(name): def get_interfaces(): # TODO class must be found out like for modules interfaces = [] - generalConfig.init() + if not generalConfig.initialized: + generalConfig.init() interface_path = path.join(generalConfig.basedir, 'frappy', 'protocol', 'interface') for filename in listdir(interface_path): diff --git a/test/conftest.py b/test/conftest.py index eba9faf..b4b1d76 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,20 +2,3 @@ import pytest - -@pytest.fixture(scope="module") -def constants(): - # setup - class Constants: - ONE = 1 - TWO = 2 - c = Constants() - yield c - # teardown - del c - - -# pylint: disable=redefined-builtin -@pytest.fixture(scope="session") -def globals(): - return {} diff --git a/test/test_cfg_editor.py b/test/test_cfg_editor.py new file mode 100644 index 0000000..3ddde76 --- /dev/null +++ b/test/test_cfg_editor.py @@ -0,0 +1,13 @@ +from pathlib import Path + +from frappy.gui.cfg_editor.utils import get_modules, get_interfaces +from frappy.lib import generalConfig + +basedir = Path(__file__).parent.parent.absolute() + + +def test_imports(): + generalConfig.testinit(basedir=basedir) + + get_modules() + get_interfaces() diff --git a/test/test_test.py b/test/test_test.py deleted file mode 100644 index c4ea004..0000000 --- a/test/test_test.py +++ /dev/null @@ -1,14 +0,0 @@ - -from frappy.gui.cfg_editor.utils import get_modules - -def test_assert(): - assert 1 - - -def test_constants(constants): - assert constants.ONE == 1 - assert constants.TWO == 2 - - -def test_imports(): - get_modules()