@@ -70,11 +70,11 @@ def test_list_tests(facade, name, expected, exes):
7070 (Catch2Facade (), "catch2_success" , "gtest" ),
7171 ],
7272)
73- def test_is_test_suite (facade , name , other_name , exes , tmpdir ):
73+ def test_is_test_suite (facade , name , other_name , exes , tmp_path ):
7474 assert facade .is_test_suite (exes .get (name ))
7575 assert not facade .is_test_suite (exes .get (other_name ))
76- tmpdir . ensure ("foo.txt" )
77- assert not facade .is_test_suite (str (tmpdir . join ("foo.txt" )))
76+ tmp_path . joinpath ("foo.txt" ). touch ( )
77+ assert not facade .is_test_suite (str (tmp_path . joinpath ("foo.txt" )))
7878
7979
8080@pytest .mark .parametrize (
@@ -228,7 +228,7 @@ def test_unknown_error(testdir, exes, mocker):
228228 assert "unknown error" in str (rep .longrepr )
229229
230230
231- def test_google_internal_errors (mocker , testdir , exes , tmpdir ):
231+ def test_google_internal_errors (mocker , testdir , exes , tmp_path ):
232232 mocker .patch .object (GoogleTestFacade , "is_test_suite" , return_value = True )
233233 mocker .patch .object (
234234 GoogleTestFacade , "list_tests" , return_value = ["FooTest.test_success" ]
@@ -246,8 +246,8 @@ def raise_error(*args, **kwargs):
246246 assert "Internal Error: calling" in str (rep .longrepr )
247247
248248 mocked .side_effect = None
249- xml_file = tmpdir . join ("results.xml" )
250- xml_file .write ("<empty/>" )
249+ xml_file = tmp_path . joinpath ("results.xml" )
250+ xml_file .write_text ("<empty/>" )
251251 mocker .patch .object (
252252 GoogleTestFacade , "_get_temp_xml_filename" , return_value = str (xml_file )
253253 )
@@ -496,7 +496,7 @@ def test_passing_files_directly_in_command_line(testdir, exes):
496496 result .stdout .fnmatch_lines (["*1 passed*" ])
497497
498498
499- def test_race_condition_on_collect (tmpdir ):
499+ def test_race_condition_on_collect (tmp_path ):
500500 """
501501 Check that collection correctly handles when a path no longer is valid.
502502
@@ -510,24 +510,29 @@ def test_race_condition_on_collect(tmpdir):
510510 """
511511 import pytest_cpp .plugin
512512
513- assert pytest_cpp .plugin .pytest_collect_file (None , tmpdir / "invalid-file" ) is None
513+ assert (
514+ pytest_cpp .plugin .pytest_collect_file (None , tmp_path / "invalid-file" ) is None
515+ )
514516
515517
516- def test_exe_mask_on_windows (tmpdir , monkeypatch ):
518+ def test_exe_mask_on_windows (tmp_path , monkeypatch ):
517519 """
518520 Test for #45: C++ tests not collected due to '*_test' mask on Windows
519521 """
520522 import pytest_cpp .plugin
521523
522524 monkeypatch .setattr (sys , "platform" , "win32" )
523525
524- fn = tmpdir .join ("generator_demo_test.exe" ).ensure (file = 1 )
526+ fn = tmp_path .joinpath ("generator_demo_test.exe" )
527+ fn .touch ()
525528 assert pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
526529
527- fn = tmpdir .join ("test_generator_demo.exe" ).ensure (file = 1 )
530+ fn = tmp_path .joinpath ("test_generator_demo.exe" )
531+ fn .touch ()
528532 assert pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
529533
530- fn = tmpdir .join ("my_generator_test_demo.exe" ).ensure (file = 1 )
534+ fn = tmp_path .joinpath ("my_generator_test_demo.exe" )
535+ fn .touch ()
531536 assert not pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
532537
533538
@@ -591,9 +596,9 @@ def test_get_whitespace(self):
591596 assert error .get_left_whitespace (" foo" ) == " "
592597 assert error .get_left_whitespace ("\t \t foo" ) == "\t \t "
593598
594- def test_get_code_context_around_line (self , tmpdir ):
595- f = tmpdir . join ("foo.py" )
596- f .write ("line1\n line2\n line3\n line4\n line5" )
599+ def test_get_code_context_around_line (self , tmp_path ):
600+ f = tmp_path . joinpath ("foo.py" )
601+ f .write_text ("line1\n line2\n line3\n line4\n line5" )
597602
598603 assert error .get_code_context_around_line (str (f ), 1 ) == ["line1" ]
599604 assert error .get_code_context_around_line (str (f ), 2 ) == ["line1" , "line2" ]
@@ -613,5 +618,5 @@ def test_get_code_context_around_line(self, tmpdir):
613618 "line5" ,
614619 ]
615620
616- invalid = str (tmpdir . join ("invalid" ))
621+ invalid = str (tmp_path . joinpath ("invalid" ))
617622 assert error .get_code_context_around_line (invalid , 10 ) == []
0 commit comments