33
44"""Tests of coverage/python.py"""
55
6+ import pathlib
67import sys
78
89import pytest
@@ -37,9 +38,8 @@ def test_get_encoded_zip_files(self, encoding):
3738 assert mod .encoding == encoding
3839
3940
40- def test_source_for_file (tmpdir ):
41- path = tmpdir .join ("a.py" )
42- src = str (path )
41+ def test_source_for_file (tmp_path : pathlib .Path ) -> None :
42+ src = str (tmp_path / "a.py" )
4343 assert source_for_file (src ) == src
4444 assert source_for_file (src + 'c' ) == src
4545 assert source_for_file (src + 'o' ) == src
@@ -48,14 +48,15 @@ def test_source_for_file(tmpdir):
4848
4949
5050@pytest .mark .skipif (not env .WINDOWS , reason = "not windows" )
51- def test_source_for_file_windows (tmpdir ) :
52- path = tmpdir . join ( "a.py" )
53- src = str (path )
51+ def test_source_for_file_windows (tmp_path : pathlib . Path ) -> None :
52+ a_py = tmp_path / "a.py"
53+ src = str (a_py )
5454
5555 # On windows if a pyw exists, it is an acceptable source
56- path_windows = tmpdir .ensure ("a.pyw" )
56+ path_windows = tmp_path / "a.pyw"
57+ path_windows .write_text ("" )
5758 assert str (path_windows ) == source_for_file (src + 'c' )
5859
5960 # If both pyw and py exist, py is preferred
60- path . ensure ( file = True )
61+ a_py . write_text ( "" )
6162 assert source_for_file (src + 'c' ) == src
0 commit comments