summaryrefslogtreecommitdiff
path: root/tests/test_concurrency.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_concurrency.py
parent0b05b45e342813b34d906e840e253a06b37133ae (diff)
downloadpython-coveragepy-git-c3ee30c1cfd133f1e36a4a8992b531a0dc7ec5a9.tar.gz
refactor(test): use tmp_path instead of tmpdir
Diffstat (limited to 'tests/test_concurrency.py')
-rw-r--r--tests/test_concurrency.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index b021d638..d08ed1ef 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -6,6 +6,7 @@
import glob
import multiprocessing
import os
+import pathlib
import random
import re
import sys
@@ -626,21 +627,22 @@ def test_coverage_stop_in_threads():
assert has_stopped_coverage == [t.ident]
-def test_thread_safe_save_data(tmpdir):
+def test_thread_safe_save_data(tmp_path: pathlib.Path) -> None:
# Non-regression test for: https://github.com/nedbat/coveragepy/issues/581
# Create some Python modules and put them in the path
- modules_dir = tmpdir.mkdir('test_modules')
+ modules_dir = tmp_path / "test_modules"
+ modules_dir.mkdir()
module_names = [f"m{i:03d}" for i in range(1000)]
for module_name in module_names:
- modules_dir.join(module_name + ".py").write("def f(): pass\n")
+ (modules_dir / (module_name + ".py")).write_text("def f(): pass\n")
# Shared variables for threads
should_run = [True]
imported = []
old_dir = os.getcwd()
- os.chdir(modules_dir.strpath)
+ os.chdir(modules_dir)
try:
# Make sure that all dummy modules can be imported.
for module_name in module_names: