summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-01-03 06:30:43 -0500
committerNed Batchelder <ned@nedbatchelder.com>2023-01-03 06:44:38 -0500
commitc3ee30c1cfd133f1e36a4a8992b531a0dc7ec5a9 (patch)
treef97bb81c7bc66e9cccad8a28cf1e57d2ceeeb347 /tests/test_python.py
parent0b05b45e342813b34d906e840e253a06b37133ae (diff)
downloadpython-coveragepy-git-c3ee30c1cfd133f1e36a4a8992b531a0dc7ec5a9.tar.gz
refactor(test): use tmp_path instead of tmpdir
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
index fd8e7b52..c8c58f4e 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -3,6 +3,7 @@
"""Tests of coverage/python.py"""
+import pathlib
import sys
import pytest
@@ -37,9 +38,8 @@ class GetZipBytesTest(CoverageTest):
assert mod.encoding == encoding
-def test_source_for_file(tmpdir):
- path = tmpdir.join("a.py")
- src = str(path)
+def test_source_for_file(tmp_path: pathlib.Path) -> None:
+ src = str(tmp_path / "a.py")
assert source_for_file(src) == src
assert source_for_file(src + 'c') == src
assert source_for_file(src + 'o') == src
@@ -48,14 +48,15 @@ def test_source_for_file(tmpdir):
@pytest.mark.skipif(not env.WINDOWS, reason="not windows")
-def test_source_for_file_windows(tmpdir):
- path = tmpdir.join("a.py")
- src = str(path)
+def test_source_for_file_windows(tmp_path: pathlib.Path) -> None:
+ a_py = tmp_path / "a.py"
+ src = str(a_py)
# On windows if a pyw exists, it is an acceptable source
- path_windows = tmpdir.ensure("a.pyw")
+ path_windows = tmp_path / "a.pyw"
+ path_windows.write_text("")
assert str(path_windows) == source_for_file(src + 'c')
# If both pyw and py exist, py is preferred
- path.ensure(file=True)
+ a_py.write_text("")
assert source_for_file(src + 'c') == src