@@ -20,6 +20,56 @@ def test_ensure_existing_file_path_accepts_existing_file(tmp_path: Path):
2020 assert normalized_path == str (file_path )
2121
2222
23+ def test_ensure_existing_file_path_rejects_non_string_missing_message (tmp_path : Path ):
24+ file_path = tmp_path / "file.txt"
25+ file_path .write_text ("content" )
26+
27+ with pytest .raises (HyperbrowserError , match = "missing_file_message must be a string" ):
28+ ensure_existing_file_path (
29+ str (file_path ),
30+ missing_file_message = 123 , # type: ignore[arg-type]
31+ not_file_message = "not-file" ,
32+ )
33+
34+
35+ def test_ensure_existing_file_path_rejects_blank_missing_message (tmp_path : Path ):
36+ file_path = tmp_path / "file.txt"
37+ file_path .write_text ("content" )
38+
39+ with pytest .raises (
40+ HyperbrowserError , match = "missing_file_message must not be empty"
41+ ):
42+ ensure_existing_file_path (
43+ str (file_path ),
44+ missing_file_message = " " ,
45+ not_file_message = "not-file" ,
46+ )
47+
48+
49+ def test_ensure_existing_file_path_rejects_non_string_not_file_message (tmp_path : Path ):
50+ file_path = tmp_path / "file.txt"
51+ file_path .write_text ("content" )
52+
53+ with pytest .raises (HyperbrowserError , match = "not_file_message must be a string" ):
54+ ensure_existing_file_path (
55+ str (file_path ),
56+ missing_file_message = "missing" ,
57+ not_file_message = 123 , # type: ignore[arg-type]
58+ )
59+
60+
61+ def test_ensure_existing_file_path_rejects_blank_not_file_message (tmp_path : Path ):
62+ file_path = tmp_path / "file.txt"
63+ file_path .write_text ("content" )
64+
65+ with pytest .raises (HyperbrowserError , match = "not_file_message must not be empty" ):
66+ ensure_existing_file_path (
67+ str (file_path ),
68+ missing_file_message = "missing" ,
69+ not_file_message = " " ,
70+ )
71+
72+
2373def test_ensure_existing_file_path_accepts_pathlike_inputs (tmp_path : Path ):
2474 file_path = tmp_path / "pathlike-file.txt"
2575 file_path .write_text ("content" )
0 commit comments