generalConfig, config: use pathlib
- switch to pathlib - represent multiple confdirs as list of Paths internally, not string with pathsep Change-Id: I1418e561641e27cd904af0762be056cd66ee1919 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34464 Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -64,7 +64,7 @@ def direc(tmp_path_factory):
|
||||
ff.touch()
|
||||
fff.touch()
|
||||
pyfile.write_text(PY_FILE)
|
||||
generalConfig.testinit(confdir=f'{a}:{b}', piddir=str(d))
|
||||
generalConfig.testinit(confdir=[a, b], piddir=d)
|
||||
return d
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ files = [('config', 'a/config_cfg.py'),
|
||||
|
||||
@pytest.mark.parametrize('file, res', files)
|
||||
def test_to_cfg_path(log, direc, file, res):
|
||||
assert to_config_path(file, log).endswith(res)
|
||||
assert str(to_config_path(file, log)).endswith(res)
|
||||
|
||||
|
||||
def test_cfg_not_existing(direc, log):
|
||||
@ -132,7 +132,7 @@ def do_asserts(ret):
|
||||
|
||||
|
||||
def test_process_file(direc, log):
|
||||
ret = process_file(str(direc / 'a' / 'pyfile_cfg.py'), log)
|
||||
ret = process_file(direc / 'a' / 'pyfile_cfg.py', log)
|
||||
do_asserts(ret)
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
import json
|
||||
import os
|
||||
from os.path import join
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from frappy.config import Param
|
||||
from frappy.core import Module, ScaledInteger, IntRange, StringType, StructOf
|
||||
@ -74,7 +75,7 @@ save_tests = [
|
||||
]
|
||||
@pytest.mark.parametrize('cfg, data', save_tests)
|
||||
def test_save(tmpdir, cfg, data):
|
||||
generalConfig.logdir = tmpdir
|
||||
generalConfig.logdir = Path(tmpdir)
|
||||
|
||||
cfg['description'] = ''
|
||||
m = Mod('m', logger, cfg, ServerStub('savetest'))
|
||||
@ -101,7 +102,7 @@ load_tests = [
|
||||
]
|
||||
@pytest.mark.parametrize('cfg, data, written', load_tests)
|
||||
def test_load(tmpdir, cfg, data, written):
|
||||
generalConfig.logdir = tmpdir
|
||||
generalConfig.logdir = Path(tmpdir)
|
||||
|
||||
os.makedirs(join(tmpdir, 'persistent'), exist_ok=True)
|
||||
with open(join(tmpdir, 'persistent', 'loadtest.m.json'), 'w', encoding='utf-8') as f:
|
||||
|
Reference in New Issue
Block a user