@@ -575,6 +575,7 @@ def test_warn_config_file_owner(tmp_path, monkeypatch):
575575 )
576576
577577
578+ @pytest .mark .skipif (IS_WINDOWS , reason = "chmod doesn't work on Windows" )
578579def test_warn_config_file_permissions (tmp_path ):
579580 c_file = tmp_path / "config.toml"
580581 c1 = ConfigManager (file_path = c_file , name = "root_parser" )
@@ -590,17 +591,30 @@ def test_warn_config_file_permissions(tmp_path):
590591 with warnings .catch_warnings (record = True ) as c :
591592 assert c1 ["b" ] is True
592593 assert len (c ) == 1
593- chmod_message = (
594- f'.\n * To change owner, run `chown $USER "{ str (c_file )} "`.\n * To restrict permissions, run `chmod 0600 "{ str (c_file )} "`.\n '
595- if not IS_WINDOWS
596- else ""
597- )
594+ chmod_message = f'.\n * To change owner, run `chown $USER "{ str (c_file )} "`.\n * To restrict permissions, run `chmod 0600 "{ str (c_file )} "`.\n '
598595 assert (
599596 str (c [0 ].message )
600597 == f"Bad owner or permissions on { str (c_file )} " + chmod_message
601598 )
602599
603600
601+ @pytest .mark .skipif (not IS_WINDOWS , reason = "Windows specific test" )
602+ def test_warn_config_file_permissions_windows (tmp_path ):
603+ c_file = tmp_path / "config.toml"
604+ c1 = ConfigManager (file_path = c_file , name = "root_parser" )
605+ c1 .add_option (name = "b" , parse_str = lambda e : e .lower () == "true" )
606+ c_file .write_text (
607+ dedent (
608+ """\
609+ b = true
610+ """
611+ )
612+ )
613+ with warnings .catch_warnings (record = True ) as c :
614+ assert c1 ["b" ] is True
615+ assert len (c ) == 0
616+
617+
604618@pytest .mark .skipif (IS_WINDOWS , reason = "chmod doesn't work on Windows" )
605619def test_log_debug_config_file_parent_dir_permissions (tmp_path , caplog ):
606620 tmp_dir = tmp_path / "tmp_dir"
0 commit comments