@@ -575,6 +575,7 @@ def test_warn_config_file_owner(tmp_path, monkeypatch):
575
575
)
576
576
577
577
578
+ @pytest .mark .skipif (IS_WINDOWS , reason = "chmod doesn't work on Windows" )
578
579
def test_warn_config_file_permissions (tmp_path ):
579
580
c_file = tmp_path / "config.toml"
580
581
c1 = ConfigManager (file_path = c_file , name = "root_parser" )
@@ -590,17 +591,30 @@ def test_warn_config_file_permissions(tmp_path):
590
591
with warnings .catch_warnings (record = True ) as c :
591
592
assert c1 ["b" ] is True
592
593
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 '
598
595
assert (
599
596
str (c [0 ].message )
600
597
== f"Bad owner or permissions on { str (c_file )} " + chmod_message
601
598
)
602
599
603
600
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
+
604
618
@pytest .mark .skipif (IS_WINDOWS , reason = "chmod doesn't work on Windows" )
605
619
def test_log_debug_config_file_parent_dir_permissions (tmp_path , caplog ):
606
620
tmp_dir = tmp_path / "tmp_dir"
0 commit comments