Skip to content

Commit a6a8399

Browse files
committed
TST: convert remaining tmpdir to tmp_path
Signed-off-by: Henry Schreiner <[email protected]>
1 parent cd082fd commit a6a8399

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def in_git_repo_context(path=os.path.curdir):
6262

6363

6464
@pytest.fixture(scope='session')
65-
def tmp_dir_session(tmpdir_factory):
65+
def tmp_path_session(tmp_path_factory):
6666
return pathlib.Path(tempfile.mkdtemp(
6767
prefix='mesonpy-test-',
68-
dir=tmpdir_factory.mktemp('test'),
68+
dir=tmp_path_factory.mktemp('test'),
6969
))
7070

7171

@@ -107,17 +107,17 @@ def fixture():
107107

108108
def generate_sdist_fixture(package):
109109
@pytest.fixture(scope='session')
110-
def fixture(tmp_dir_session):
110+
def fixture(tmp_path_session):
111111
with cd_package(package), in_git_repo_context():
112-
return tmp_dir_session / mesonpy.build_sdist(tmp_dir_session)
112+
return tmp_path_session / mesonpy.build_sdist(tmp_path_session)
113113
return fixture
114114

115115

116116
def generate_wheel_fixture(package):
117117
@pytest.fixture(scope='session')
118-
def fixture(tmp_dir_session):
118+
def fixture(tmp_path_session):
119119
with cd_package(package), in_git_repo_context():
120-
return tmp_dir_session / mesonpy.build_wheel(tmp_dir_session)
120+
return tmp_path_session / mesonpy.build_wheel(tmp_path_session)
121121
return fixture
122122

123123

tests/docs/examples/test_spam.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
from .conftest import build_project_wheel, examples_dir
99

1010

11-
def test_build_and_import(venv, tmp_dir_session):
11+
def test_build_and_import(venv, tmp_path_session):
1212
"""Test that the wheel for the spam example builds, installs, and imports."""
1313

1414
if sys.version_info < (3, 8):
1515
# The test project requires Python >= 3.8.
1616
with pytest.raises(mesonpy.MesonBuilderError, match=r'Unsupported Python version `3.7.\d+`'):
17-
build_project_wheel(package=examples_dir / 'spam', outdir=tmp_dir_session)
17+
build_project_wheel(package=examples_dir / 'spam', outdir=tmp_path_session)
1818

1919
else:
20-
wheel = build_project_wheel(package=examples_dir / 'spam', outdir=tmp_dir_session)
20+
wheel = build_project_wheel(package=examples_dir / 'spam', outdir=tmp_path_session)
2121

2222
subprocess.run(
2323
[venv.executable, '-m', 'pip', 'install', wheel],

tests/test_pep517.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def run(cmd: List[str], *args: object, **kwargs: object) -> subprocess.Completed
5353
assert set(mesonpy.get_requires_for_build_wheel()) == expected
5454

5555

56-
def test_invalid_config_settings(package_pure, tmp_dir_session):
56+
def test_invalid_config_settings(package_pure, tmp_path_session):
5757
raises_error = pytest.raises(mesonpy.ConfigError, match='Unknown config setting: invalid')
5858

5959
with raises_error:
60-
mesonpy.build_sdist(tmp_dir_session, {'invalid': ()})
60+
mesonpy.build_sdist(tmp_path_session, {'invalid': ()})
6161
with raises_error:
62-
mesonpy.build_wheel(tmp_dir_session, {'invalid': ()})
62+
mesonpy.build_wheel(tmp_path_session, {'invalid': ()})

tests/test_project.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_unsupported_python_version(package_unsupported_python_version):
5555
sys.version_info < (3, 8),
5656
reason="unittest.mock doesn't support the required APIs for this test",
5757
)
58-
def test_user_args(package_user_args, mocker, tmp_dir_session):
58+
def test_user_args(package_user_args, mocker, tmp_path_session):
5959
mocker.patch('mesonpy.Project._meson')
6060

6161
def last_two_meson_args():
@@ -64,7 +64,7 @@ def last_two_meson_args():
6464
]
6565

6666
# create the build directory ourselves because Project._meson is mocked
67-
builddir = str(tmp_dir_session / 'build')
67+
builddir = str(tmp_path_session / 'build')
6868
subprocess.run(['meson', 'setup', '.', builddir], check=True)
6969

7070
config_settings = {
@@ -76,9 +76,9 @@ def last_two_meson_args():
7676
}
7777

7878
with contextlib.suppress(Exception):
79-
mesonpy.build_sdist(tmp_dir_session / 'dist', config_settings)
79+
mesonpy.build_sdist(tmp_path_session / 'dist', config_settings)
8080
with contextlib.suppress(Exception):
81-
mesonpy.build_wheel(tmp_dir_session / 'dist', config_settings)
81+
mesonpy.build_wheel(tmp_path_session / 'dist', config_settings)
8282

8383
assert last_two_meson_args() == [
8484
# sdist
@@ -92,6 +92,6 @@ def last_two_meson_args():
9292

9393

9494
@pytest.mark.parametrize('package', ('top-level', 'meson-args'))
95-
def test_unknown_user_args(package, tmp_dir_session):
95+
def test_unknown_user_args(package, tmp_path_session):
9696
with pytest.raises(mesonpy.ConfigError):
97-
mesonpy.Project(package_dir / f'unknown-user-args-{package}', tmp_dir_session)
97+
mesonpy.Project(package_dir / f'unknown-user-args-{package}', tmp_path_session)

tests/test_sdist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_contents_subdirs(sdist_subdirs):
4242
}
4343

4444

45-
def test_contents_unstaged(package_pure, tmpdir):
45+
def test_contents_unstaged(package_pure, tmp_path):
4646
new_data = textwrap.dedent('''
4747
def bar():
4848
return 'foo'
@@ -56,13 +56,13 @@ def bar():
5656
with open('pure.py', 'w') as f, open('crap', 'x'):
5757
f.write(new_data)
5858

59-
sdist_path = mesonpy.build_sdist(os.fspath(tmpdir))
59+
sdist_path = mesonpy.build_sdist(os.fspath(tmp_path))
6060
finally:
6161
with open('pure.py', 'w') as f:
6262
f.write(old_data)
6363
os.unlink('crap')
6464

65-
with tarfile.open(tmpdir / sdist_path, 'r:gz') as sdist:
65+
with tarfile.open(tmp_path / sdist_path, 'r:gz') as sdist:
6666
names = set(sdist.getnames())
6767
read_data = sdist.extractfile('pure-1.0.0/pure.py').read().replace(b'\r\n', b'\n')
6868

tests/test_wheel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,20 @@ def test_detect_wheel_tag_script(wheel_executable):
188188

189189

190190
@pytest.mark.skipif(platform.system() != 'Linux', reason='Unsupported on this platform for now')
191-
def test_rpath(wheel_link_against_local_lib, tmpdir):
191+
def test_rpath(wheel_link_against_local_lib, tmp_path):
192192
artifact = wheel.wheelfile.WheelFile(wheel_link_against_local_lib)
193-
artifact.extractall(tmpdir)
193+
artifact.extractall(tmp_path)
194194

195-
elf = mesonpy._elf.ELF(tmpdir / f'example{EXT_SUFFIX}')
195+
elf = mesonpy._elf.ELF(tmp_path / f'example{EXT_SUFFIX}')
196196
assert '$ORIGIN/.link_against_local_lib.mesonpy.libs' in elf.rpath
197197

198198

199199
@pytest.mark.skipif(platform.system() != 'Linux', reason='Unsupported on this platform for now')
200-
def test_uneeded_rpath(wheel_purelib_and_platlib, tmpdir):
200+
def test_uneeded_rpath(wheel_purelib_and_platlib, tmp_path):
201201
artifact = wheel.wheelfile.WheelFile(wheel_purelib_and_platlib)
202-
artifact.extractall(tmpdir)
202+
artifact.extractall(tmp_path)
203203

204-
elf = mesonpy._elf.ELF(tmpdir / f'plat{EXT_SUFFIX}')
204+
elf = mesonpy._elf.ELF(tmp_path / f'plat{EXT_SUFFIX}')
205205
if elf.rpath:
206206
# elf.rpath is a frozenset, so iterate over it. An rpath may be
207207
# present, e.g. when conda is used (rpath will be <conda-prefix>/lib/)

0 commit comments

Comments
 (0)