31 lines
750 B
Python
31 lines
750 B
Python
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"
|