11import tempfile
22from copy import deepcopy
3- from typing import Dict , List , Optional
3+ from pathlib import Path
4+ from typing import Dict , List , Optional , Tuple
45
56import pytest
67import yaml
2526
2627
2728@pytest .fixture
28- def config_file ():
29+ def config_file () -> str :
2930 with tempfile .NamedTemporaryFile (delete = False ) as f :
3031 f .write (yaml .dump (CONFIG_DATA ).encode ())
3132 return f .name
@@ -55,6 +56,11 @@ class ListConfig(BaseModel):
5556 str_list_param : Optional [str ] = None
5657
5758
59+ class UnsafeConfig (BaseModel ):
60+ tuple_param : Tuple [int , int ] = (1 , 2 )
61+ path_param : Path = Path .cwd ()
62+
63+
5864class Config (LuxonisConfig ):
5965 sub_config : SubConfig
6066 sub_config_default : SubConfigDefault = SubConfigDefault ()
@@ -63,6 +69,7 @@ class Config(LuxonisConfig):
6369 list_config : List [ListConfig ] = []
6470 nested_list_param : List [List [int ]] = []
6571 nested_dict_param : Dict [str , Dict [str , int ]] = {}
72+ unsafe_config : UnsafeConfig = UnsafeConfig ()
6673
6774
6875def test_invalid_config_path ():
@@ -267,3 +274,12 @@ def test_get(config_file: str):
267274
268275def test_environ ():
269276 assert environ .model_dump () == {}
277+
278+
279+ def test_safe_load (config_file : str ):
280+ cfg = Config .get_config (config_file )
281+ with tempfile .NamedTemporaryFile (delete = False ) as f :
282+ cfg .save_data (f .name )
283+
284+ cfg2 = Config .get_config (f .name )
285+ assert cfg == cfg2
0 commit comments