@@ -70,11 +70,11 @@ def test_list_tests(facade, name, expected, exes):
70
70
(Catch2Facade (), "catch2_success" , "gtest" ),
71
71
],
72
72
)
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 ):
74
74
assert facade .is_test_suite (exes .get (name ))
75
75
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" )))
78
78
79
79
80
80
@pytest .mark .parametrize (
@@ -228,7 +228,7 @@ def test_unknown_error(testdir, exes, mocker):
228
228
assert "unknown error" in str (rep .longrepr )
229
229
230
230
231
- def test_google_internal_errors (mocker , testdir , exes , tmpdir ):
231
+ def test_google_internal_errors (mocker , testdir , exes , tmp_path ):
232
232
mocker .patch .object (GoogleTestFacade , "is_test_suite" , return_value = True )
233
233
mocker .patch .object (
234
234
GoogleTestFacade , "list_tests" , return_value = ["FooTest.test_success" ]
@@ -246,8 +246,8 @@ def raise_error(*args, **kwargs):
246
246
assert "Internal Error: calling" in str (rep .longrepr )
247
247
248
248
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/>" )
251
251
mocker .patch .object (
252
252
GoogleTestFacade , "_get_temp_xml_filename" , return_value = str (xml_file )
253
253
)
@@ -496,7 +496,7 @@ def test_passing_files_directly_in_command_line(testdir, exes):
496
496
result .stdout .fnmatch_lines (["*1 passed*" ])
497
497
498
498
499
- def test_race_condition_on_collect (tmpdir ):
499
+ def test_race_condition_on_collect (tmp_path ):
500
500
"""
501
501
Check that collection correctly handles when a path no longer is valid.
502
502
@@ -510,24 +510,29 @@ def test_race_condition_on_collect(tmpdir):
510
510
"""
511
511
import pytest_cpp .plugin
512
512
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
+ )
514
516
515
517
516
- def test_exe_mask_on_windows (tmpdir , monkeypatch ):
518
+ def test_exe_mask_on_windows (tmp_path , monkeypatch ):
517
519
"""
518
520
Test for #45: C++ tests not collected due to '*_test' mask on Windows
519
521
"""
520
522
import pytest_cpp .plugin
521
523
522
524
monkeypatch .setattr (sys , "platform" , "win32" )
523
525
524
- fn = tmpdir .join ("generator_demo_test.exe" ).ensure (file = 1 )
526
+ fn = tmp_path .joinpath ("generator_demo_test.exe" )
527
+ fn .touch ()
525
528
assert pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
526
529
527
- fn = tmpdir .join ("test_generator_demo.exe" ).ensure (file = 1 )
530
+ fn = tmp_path .joinpath ("test_generator_demo.exe" )
531
+ fn .touch ()
528
532
assert pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
529
533
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 ()
531
536
assert not pytest_cpp .plugin .matches_any_mask (fn , ["test_*" , "*_test" ])
532
537
533
538
@@ -591,9 +596,9 @@ def test_get_whitespace(self):
591
596
assert error .get_left_whitespace (" foo" ) == " "
592
597
assert error .get_left_whitespace ("\t \t foo" ) == "\t \t "
593
598
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" )
597
602
598
603
assert error .get_code_context_around_line (str (f ), 1 ) == ["line1" ]
599
604
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):
613
618
"line5" ,
614
619
]
615
620
616
- invalid = str (tmpdir . join ("invalid" ))
621
+ invalid = str (tmp_path . joinpath ("invalid" ))
617
622
assert error .get_code_context_around_line (invalid , 10 ) == []
0 commit comments