@@ -58,6 +58,11 @@ def tmp_files_helper(cwd: Path, to_create: files) -> None:
5858def tmp_files (tmp_path : Path ) -> Callable [[files ], Path ]:
5959 def create_tmp_files (to_create : files ) -> Path :
6060 tmp_files_helper (tmp_path , to_create )
61+ # Automatically fix file permissions
62+ if "config.toml" in to_create :
63+ (tmp_path / "config.toml" ).chmod (stat .S_IRUSR | stat .S_IWUSR )
64+ if "connections.toml" in to_create :
65+ (tmp_path / "connections.toml" ).chmod (stat .S_IRUSR | stat .S_IWUSR )
6166 return tmp_path
6267
6368 return create_tmp_files
@@ -117,7 +122,7 @@ def test_simple_config_read(tmp_files):
117122 name = "output_format" ,
118123 choices = ("json" , "yaml" , "toml" ),
119124 )
120- TEST_PARSER .add_subparser (settings_parser )
125+ TEST_PARSER .add_submanager (settings_parser )
121126 assert TEST_PARSER ["connections" ] == {
122127 "snowflake" : {
123128 "account" : "snowflake" ,
@@ -170,7 +175,7 @@ def test_simple_config_read_sliced(tmp_files):
170175 name = "output_format" ,
171176 choices = ("json" , "yaml" , "toml" ),
172177 )
173- TEST_PARSER .add_subparser (settings_parser )
178+ TEST_PARSER .add_submanager (settings_parser )
174179 assert TEST_PARSER ["connections" ] == {
175180 "snowflake" : {
176181 "account" : "snowflake" ,
@@ -209,7 +214,7 @@ def test_missing_value(tmp_files):
209214 name = "output_format" ,
210215 choices = ("json" , "yaml" , "toml" ),
211216 )
212- TEST_PARSER .add_subparser (settings_parser )
217+ TEST_PARSER .add_submanager (settings_parser )
213218 assert TEST_PARSER ["connections" ] == {
214219 "snowflake" : {
215220 "account" : "snowflake" ,
@@ -266,7 +271,7 @@ def test_missing_value_sliced(tmp_files):
266271 name = "output_format" ,
267272 choices = ("json" , "yaml" , "toml" ),
268273 )
269- TEST_PARSER .add_subparser (settings_parser )
274+ TEST_PARSER .add_submanager (settings_parser )
270275 assert TEST_PARSER ["connections" ] == {
271276 "snowflake" : {
272277 "account" : "snowflake" ,
@@ -322,7 +327,7 @@ def test_only_in_slice(tmp_files):
322327 name = "output_format" ,
323328 choices = ("json" , "yaml" , "toml" ),
324329 )
325- TEST_PARSER .add_subparser (settings_parser )
330+ TEST_PARSER .add_submanager (settings_parser )
326331 with pytest .raises (
327332 ConfigSourceError ,
328333 match = "Configuration option 'connections' is not defined.*" ,
@@ -335,8 +340,8 @@ def test_simple_nesting(monkeypatch, tmp_path):
335340 c2 = ConfigManager (name = "sb" )
336341 c3 = ConfigManager (name = "sb" )
337342 c3 .add_option (name = "b" , parse_str = lambda e : e .lower () == "true" )
338- c2 .add_subparser (c3 )
339- c1 .add_subparser (c2 )
343+ c2 .add_submanager (c3 )
344+ c1 .add_submanager (c2 )
340345 with monkeypatch .context () as m :
341346 m .setenv ("SNOWFLAKE_SB_SB_B" , "TrUe" )
342347 assert c1 ["sb" ]["sb" ]["b" ] is True
@@ -347,7 +352,7 @@ def test_complicated_nesting(monkeypatch, tmp_path):
347352 c1 = ConfigManager (file_path = c_file , name = "root_parser" )
348353 c2 = ConfigManager (file_path = tmp_path / "config2.toml" , name = "sp" )
349354 c2 .add_option (name = "b" , parse_str = lambda e : e .lower () == "true" )
350- c1 .add_subparser (c2 )
355+ c1 .add_submanager (c2 )
351356 c_file .write_text (
352357 dedent (
353358 """\
@@ -361,6 +366,7 @@ def test_complicated_nesting(monkeypatch, tmp_path):
361366 """
362367 )
363368 )
369+ c_file .chmod (stat .S_IRUSR | stat .S_IWUSR )
364370 assert c1 ["sp" ]["b" ] is True
365371
366372
@@ -381,6 +387,7 @@ def test_error_invalid_toml(tmp_path):
381387 """
382388 )
383389 )
390+ c_file .chmod (stat .S_IRUSR | stat .S_IWUSR )
384391 with pytest .raises (
385392 ConfigSourceError ,
386393 match = re .escape (f"An unknown error happened while loading '{ str (c_file )} '" ),
@@ -393,7 +400,7 @@ def test_error_invalid_toml(tmp_path):
393400
394401def test_error_child_conflict ():
395402 cp = ConfigManager (name = "test_parser" )
396- cp .add_subparser (ConfigManager (name = "b" ))
403+ cp .add_submanager (ConfigManager (name = "b" ))
397404 with pytest .raises (
398405 ConfigManagerError ,
399406 match = "'b' sub-manager, or option conflicts with a child element of 'test_parser'" ,
@@ -654,7 +661,8 @@ def test_deprecationwarning_config_parser():
654661 str (w [- 1 ].message )
655662 == "CONFIG_PARSER has been deprecated, use CONFIG_MANAGER instead"
656663 )
657- assert config_manager .CONFIG_MANAGER is config_manager .CONFIG_PARSER
664+ with warnings .catch_warnings (record = True ) as w :
665+ assert config_manager .CONFIG_MANAGER is config_manager .CONFIG_PARSER
658666
659667
660668def test_configoption_default_value (tmp_path , monkeypatch ):
@@ -702,6 +710,7 @@ def test_defaultconnectionname(tmp_path, monkeypatch):
702710 """
703711 )
704712 )
713+ c_file .chmod (stat .S_IRUSR | stat .S_IWUSR )
705714 # re-cache config file from disk
706715 CONFIG_MANAGER .file_path = c_file
707716 CONFIG_MANAGER .conf_file_cache = None
0 commit comments