File tree 5 files changed +21
-17
lines changed
Filter options
5 files changed +21
-17
lines changed
Original file line number Diff line number Diff line change 2
2
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3
3
4
4
[tool:pytest]
5
- addopts = -q -n auto --strict-markers --no-flaky-report -rfEX --failed-first
5
+ addopts = -q -n auto -p no:legacypath - -strict-markers --no-flaky-report -rfEX --failed-first
6
6
python_classes = *Test
7
7
markers =
8
8
expensive: too slow to run during " make smoke"
Original file line number Diff line number Diff line change 29
29
import os
30
30
import shutil
31
31
import time
32
+
32
33
from pathlib import Path
33
34
34
35
import pytest
@@ -64,7 +65,7 @@ def pytest_sessionstart(self, session):
64
65
if not self .running_all :
65
66
return
66
67
67
- tests_csv_dir = Path ( session .startdir ) .resolve () / "tmp/tests_csv"
68
+ tests_csv_dir = session .startpath .resolve () / "tmp/tests_csv"
68
69
self .tests_csv = tests_csv_dir / f"{ self .worker } .csv"
69
70
70
71
if self .worker == "none" :
Original file line number Diff line number Diff line change 12
12
import os .path
13
13
import sys
14
14
15
- from typing import Tuple
15
+ from typing import Iterator , Tuple
16
16
17
17
import pytest
18
18
@@ -57,10 +57,10 @@ class TempDirMixin:
57
57
run_in_temp_dir = True
58
58
59
59
@pytest .fixture (autouse = True )
60
- def _temp_dir (self , tmpdir_factory ) :
60
+ def _temp_dir (self , tmp_path_factory : pytest . TempPathFactory ) -> Iterator [ None ] :
61
61
"""Create a temp dir for the tests, if they want it."""
62
62
if self .run_in_temp_dir :
63
- tmpdir = tmpdir_factory .mktemp ("t" )
63
+ tmpdir = tmp_path_factory .mktemp ("t" )
64
64
self .temp_dir = str (tmpdir )
65
65
with change_dir (self .temp_dir ):
66
66
# Modules should be importable from this temp directory. We don't
Original file line number Diff line number Diff line change 6
6
import glob
7
7
import multiprocessing
8
8
import os
9
+ import pathlib
9
10
import random
10
11
import re
11
12
import sys
@@ -626,21 +627,22 @@ def run_thread(): # pragma: nested
626
627
assert has_stopped_coverage == [t .ident ]
627
628
628
629
629
- def test_thread_safe_save_data (tmpdir ) :
630
+ def test_thread_safe_save_data (tmp_path : pathlib . Path ) -> None :
630
631
# Non-regression test for: https://github.com/nedbat/coveragepy/issues/581
631
632
632
633
# Create some Python modules and put them in the path
633
- modules_dir = tmpdir .mkdir ('test_modules' )
634
+ modules_dir = tmp_path / "test_modules"
635
+ modules_dir .mkdir ()
634
636
module_names = [f"m{ i :03d} " for i in range (1000 )]
635
637
for module_name in module_names :
636
- modules_dir . join (module_name + ".py" ). write ("def f(): pass\n " )
638
+ ( modules_dir / (module_name + ".py" )). write_text ("def f(): pass\n " )
637
639
638
640
# Shared variables for threads
639
641
should_run = [True ]
640
642
imported = []
641
643
642
644
old_dir = os .getcwd ()
643
- os .chdir (modules_dir . strpath )
645
+ os .chdir (modules_dir )
644
646
try :
645
647
# Make sure that all dummy modules can be imported.
646
648
for module_name in module_names :
Original file line number Diff line number Diff line change 3
3
4
4
"""Tests of coverage/python.py"""
5
5
6
+ import pathlib
6
7
import sys
7
8
8
9
import pytest
@@ -37,9 +38,8 @@ def test_get_encoded_zip_files(self, encoding):
37
38
assert mod .encoding == encoding
38
39
39
40
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" )
43
43
assert source_for_file (src ) == src
44
44
assert source_for_file (src + 'c' ) == src
45
45
assert source_for_file (src + 'o' ) == src
@@ -48,14 +48,15 @@ def test_source_for_file(tmpdir):
48
48
49
49
50
50
@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 )
54
54
55
55
# 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 ("" )
57
58
assert str (path_windows ) == source_for_file (src + 'c' )
58
59
59
60
# If both pyw and py exist, py is preferred
60
- path . ensure ( file = True )
61
+ a_py . write_text ( "" )
61
62
assert source_for_file (src + 'c' ) == src
You can’t perform that action at this time.
0 commit comments