moved tests out of src, added more test cases
This commit is contained in:
@@ -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
|
|
||||||
30
tests/test_config.py
Normal file
30
tests/test_config.py
Normal file
@@ -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"
|
||||||
Reference in New Issue
Block a user