@@ -79,6 +79,12 @@ def parse_reqfile(
79
79
)
80
80
81
81
82
+ def path_to_string (p : Path ) -> str :
83
+ # Escape the back slashes in windows path before using it
84
+ # in a regex
85
+ return str (p ).replace ("\\ " , "\\ \\ " )
86
+
87
+
82
88
def test_read_file_url (tmp_path : Path , session : PipSession ) -> None :
83
89
reqs = tmp_path .joinpath ("requirements.txt" )
84
90
reqs .write_text ("foo" )
@@ -360,8 +366,8 @@ def test_recursive_requirements_file(
360
366
with pytest .raises (
361
367
RecursionError ,
362
368
match = (
363
- f"{ req_files [0 ]} recursively references itself"
364
- f" in { req_files [req_file_count - 1 ]} "
369
+ f"{ path_to_string ( req_files [0 ]) } recursively references itself"
370
+ f" in { path_to_string ( req_files [req_file_count - 1 ]) } "
365
371
),
366
372
):
367
373
list (parse_requirements (filename = str (req_files [0 ]), session = session ))
@@ -371,9 +377,10 @@ def test_recursive_requirements_file(
371
377
with pytest .raises (
372
378
RecursionError ,
373
379
match = (
374
- f"{ req_files [req_file_count - 2 ]} recursively references itself "
375
- f"in { req_files [req_file_count - 1 ]} and again in"
376
- f" { req_files [req_file_count - 3 ]} "
380
+ f"{ path_to_string (req_files [req_file_count - 2 ])} recursively"
381
+ " references itself in"
382
+ f" { path_to_string (req_files [req_file_count - 1 ])} and again in"
383
+ f" { path_to_string (req_files [req_file_count - 3 ])} "
377
384
),
378
385
):
379
386
list (parse_requirements (filename = str (req_files [0 ]), session = session ))
@@ -393,7 +400,8 @@ def test_recursive_relative_requirements_file(
393
400
with pytest .raises (
394
401
RecursionError ,
395
402
match = (
396
- f"{ root_req_file } recursively references itself in { level_2_req_file } "
403
+ f"{ path_to_string (root_req_file )} recursively references itself in"
404
+ f" { path_to_string (level_2_req_file )} "
397
405
),
398
406
):
399
407
list (parse_requirements (filename = str (root_req_file ), session = session ))
0 commit comments