diff --git a/test/unit/python/jw/pkg/lib/ProjectConf/test.py b/test/unit/python/jw/pkg/lib/ProjectConf/test.py index 36a3f558..6f359ece 100644 --- a/test/unit/python/jw/pkg/lib/ProjectConf/test.py +++ b/test/unit/python/jw/pkg/lib/ProjectConf/test.py @@ -1,14 +1,25 @@ +import os import tempfile from jw.pkg.lib.ProjectConf import ProjectConf # -- Helper: create temp file and read it -- +_tmpfiles: list[str] = [] + def _load(text: str) -> ProjectConf: with tempfile.NamedTemporaryFile(mode='w', suffix='.conf', delete=False) as f: f.write(text) f.flush() + _tmpfiles.append(f.name) return ProjectConf.read(f.name) + +def _cleanup(): + for _p in _tmpfiles: + os.unlink(_p) + del _p + _tmpfiles.clear() + # -- Basic construction -- pc = _load('[section]\nkey = value\n') @@ -250,4 +261,5 @@ assert pc.get_str('section', 'not_a_key') == '[bracket]' pc = _load('[section]\nlist = "a", "b", "c"\n') assert pc.get_list('section', 'list') == ['a', 'b', 'c'] +_cleanup() print('All ProjectConf tests passed')