@@ -59,11 +59,11 @@ def node_path(session: Union[pytest.Item, pytest.Session]) -> PathCompat:
5959 return session .fspath
6060
6161
62- def relative_to (path : PathCompat , base : PathCompat ) -> str :
62+ def posix_relative_to (path : PathCompat , base : PathCompat ) -> str :
6363 if hasattr (path , 'relative_to' ):
64- return str ( path .relative_to (base ))
64+ return path .relative_to (base ). as_posix ( )
6565 else :
66- return str (path .relto (base )) # type: ignore
66+ return Path (path .relto (base )). as_posix ( ) # type: ignore
6767
6868
6969def item_name (item : _pytest .nodes .Node ) -> Tuple [str , ...]:
@@ -243,7 +243,7 @@ def pytest_collection_modifyitems(
243243 ) -> None :
244244 self .logger .debug ('called hook pytest_collection_modifyitems' )
245245 for idx , item in enumerate (items ):
246- test_path = relative_to (node_path (item ), node_path (session ))
246+ test_path = posix_relative_to (node_path (item ), node_path (session ))
247247 test_name = item_name (item )
248248 if (test_path , test_name ) in self .quarantined_tests :
249249 self .logger .info (
@@ -261,14 +261,14 @@ def pytest_runtest_protocol(self, item: pytest.Item, nextitem: Optional[pytest.I
261261 ihook .pytest_runtest_logstart (nodeid = item .nodeid , location = item .location )
262262
263263 assert self .session
264- test_filename = relative_to (node_path (item ), node_path (self .session ))
264+ test_filename = posix_relative_to (node_path (item ), node_path (self .session ))
265265 test_name = item_name (item )
266266 for attempt in range (item .config .option .unflakable_failure_retries + 1 ):
267267 if attempt > 0 :
268268 self .logger .info (
269269 'retrying test `%s` in file %s (attempt %d of %d)' ,
270270 '.' .join (test_name ),
271- relative_to (node_path (item ), node_path (item .session )),
271+ posix_relative_to (node_path (item ), node_path (item .session )),
272272 attempt + 1 ,
273273 item .config .option .unflakable_failure_retries + 1 ,
274274 )
@@ -304,7 +304,7 @@ def pytest_runtest_makereport(
304304 if item .parent :
305305 pass
306306
307- test_filename = relative_to (node_path (item ), node_path (item .session ))
307+ test_filename = posix_relative_to (node_path (item ), node_path (item .session ))
308308 test_name = item_name (item )
309309 is_quarantined = (test_filename , test_name ) in self .quarantined_tests and (
310310 self .quarantine_mode == QuarantineMode .IGNORE_FAILURES )
0 commit comments