@@ -46,6 +46,23 @@ def test_ensure_existing_file_path_rejects_blank_missing_message(tmp_path: Path)
4646 )
4747
4848
49+ def test_ensure_existing_file_path_rejects_control_chars_in_missing_message (
50+ tmp_path : Path ,
51+ ):
52+ file_path = tmp_path / "file.txt"
53+ file_path .write_text ("content" )
54+
55+ with pytest .raises (
56+ HyperbrowserError ,
57+ match = "missing_file_message must not contain control characters" ,
58+ ):
59+ ensure_existing_file_path (
60+ str (file_path ),
61+ missing_file_message = "missing\t message" ,
62+ not_file_message = "not-file" ,
63+ )
64+
65+
4966def test_ensure_existing_file_path_rejects_non_string_not_file_message (tmp_path : Path ):
5067 file_path = tmp_path / "file.txt"
5168 file_path .write_text ("content" )
@@ -70,6 +87,23 @@ def test_ensure_existing_file_path_rejects_blank_not_file_message(tmp_path: Path
7087 )
7188
7289
90+ def test_ensure_existing_file_path_rejects_control_chars_in_not_file_message (
91+ tmp_path : Path ,
92+ ):
93+ file_path = tmp_path / "file.txt"
94+ file_path .write_text ("content" )
95+
96+ with pytest .raises (
97+ HyperbrowserError ,
98+ match = "not_file_message must not contain control characters" ,
99+ ):
100+ ensure_existing_file_path (
101+ str (file_path ),
102+ missing_file_message = "missing" ,
103+ not_file_message = "not-file\n message" ,
104+ )
105+
106+
73107def test_ensure_existing_file_path_accepts_pathlike_inputs (tmp_path : Path ):
74108 file_path = tmp_path / "pathlike-file.txt"
75109 file_path .write_text ("content" )
0 commit comments