From 6a22ecb591311088fd66077495e576f2a90f8125 Mon Sep 17 00:00:00 2001 From: sroth Date: Thu, 8 May 2025 13:31:24 +0200 Subject: [PATCH] moved tests out of src, added more test cases --- src/tests/test_config.py | 24 ------------------------ {src/tests => tests}/__init__.py | 0 tests/test_config.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 24 deletions(-) delete mode 100644 src/tests/test_config.py rename {src/tests => tests}/__init__.py (100%) create mode 100644 tests/test_config.py diff --git a/src/tests/test_config.py b/src/tests/test_config.py deleted file mode 100644 index b5562b5..0000000 --- a/src/tests/test_config.py +++ /dev/null @@ -1,24 +0,0 @@ -from config import Config - - -def test_construction(): - assert Config() - -def test__save(): - assert False - - -def test__load(): - assert False - - -def test_add_section(): - assert False - - -def test_set(): - assert False - - -def test_get(): - assert False diff --git a/src/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/tests/__init__.py rename to tests/__init__.py diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..40bbe8c --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,30 @@ +import os +from typing import assert_type + +import pytest + +from src.config import Config + + +@pytest.fixture +def config() -> Config: + config = Config(path="testfiles", filename="configtest.ini") + return config + +def teardown_config(): + print("tearing down config test") + +def test_construction(config): + assert_type(config, Config) + +def test_file_creation(config): + config._save() + assert os.path.isfile(os.path.join(config.path, config.filename)) + +def test_add_section(config): + config.add_section("test_section") + assert "test_section" in config.parser.sections() + +def test_set_and_get(config): + config.set(section="section", option="option", value="value") + assert config.get(section="section", option="option") == "value"