@@ -43,7 +43,7 @@ def compute_uncompressed_hash(inp: Path) -> str:
4343
4444
4545@pytest .mark .usefixtures ("package_simple_pyproject_ext" )
46- def test_pep517_sdist ():
46+ def test_pep517_sdist (tmp_path : Path ):
4747 expected_metadata = (
4848 inspect .cleandoc (
4949 """
@@ -57,8 +57,8 @@ def test_pep517_sdist():
5757 )
5858 + "\n \n "
5959 )
60- dist = Path ( "dist" )
61- out = build_sdist (" dist" )
60+ dist = tmp_path / "dist"
61+ out = build_sdist (str ( dist ) )
6262
6363 (sdist ,) = dist .iterdir ()
6464 assert sdist .name == "cmake_example-0.0.1.tar.gz"
@@ -83,11 +83,11 @@ def test_pep517_sdist():
8383
8484
8585@mark_hashes_different
86- def test_pep517_sdist_hash (monkeypatch , package_simple_pyproject_ext ):
86+ def test_pep517_sdist_hash (monkeypatch , package_simple_pyproject_ext , tmp_path : Path ):
8787 # Unset SOURCE_DATE_EPOCH in order to guarantee the hash match
8888 monkeypatch .delenv ("SOURCE_DATE_EPOCH" , raising = False )
89- dist = Path ( "dist" )
90- out = build_sdist (" dist" )
89+ dist = tmp_path / "dist"
90+ out = build_sdist (str ( dist ) )
9191 sdist = dist / out
9292 hash = compute_uncompressed_hash (sdist )
9393 assert hash == package_simple_pyproject_ext .sdist_hash
@@ -99,18 +99,17 @@ def test_pep517_sdist_hash(monkeypatch, package_simple_pyproject_ext):
9999
100100
101101@pytest .mark .usefixtures ("package_simple_pyproject_ext" )
102- def test_pep517_sdist_time_hash ():
103- dist = Path ( "dist" )
102+ def test_pep517_sdist_time_hash (tmp_path : Path ):
103+ dist = tmp_path / "dist"
104104
105- out = build_sdist (" dist" )
105+ out = build_sdist (str ( dist ) )
106106 sdist = dist / out
107107 hash1 = hashlib .sha256 (sdist .read_bytes ()).hexdigest ()
108108
109109 time .sleep (2 )
110110 Path ("src/main.cpp" ).touch ()
111111
112- if Path ("dist" ).is_dir ():
113- shutil .rmtree ("dist" )
112+ shutil .rmtree (dist )
114113
115114 out = build_sdist (str (dist ))
116115 sdist = dist / out
@@ -121,17 +120,16 @@ def test_pep517_sdist_time_hash():
121120
122121
123122@pytest .mark .usefixtures ("package_simple_pyproject_ext" )
124- def test_pep517_sdist_time_hash_nonreproducable ():
125- dist = Path ( "dist" )
123+ def test_pep517_sdist_time_hash_nonreproducable (tmp_path : Path ):
124+ dist = tmp_path / "dist"
126125
127- out = build_sdist (" dist" , {"sdist.reproducible" : "false" })
126+ out = build_sdist (str ( dist ) , {"sdist.reproducible" : "false" })
128127 sdist = dist / out
129128 hash1 = hashlib .sha256 (sdist .read_bytes ()).hexdigest ()
130129
131130 time .sleep (2 )
132131
133- if Path ("dist" ).is_dir ():
134- shutil .rmtree ("dist" )
132+ shutil .rmtree (dist )
135133
136134 out = build_sdist (str (dist ))
137135 sdist = dist / out
@@ -144,9 +142,9 @@ def test_pep517_sdist_time_hash_nonreproducable():
144142@mark_hashes_different
145143@pytest .mark .parametrize ("reverse_order" , [False , True ])
146144def test_pep517_sdist_time_hash_set_epoch (
147- monkeypatch , reverse_order , package_simple_pyproject_ext
145+ monkeypatch , reverse_order , package_simple_pyproject_ext , tmp_path : Path
148146):
149- dist = Path ( "dist" )
147+ dist = tmp_path / "dist"
150148 monkeypatch .setenv (
151149 "SOURCE_DATE_EPOCH" , package_simple_pyproject_ext .source_date_epoch
152150 )
@@ -176,11 +174,12 @@ def each_unignored_file_ordered(*args, **kwargs):
176174 ("SKBUILD_CMAKE_ARGS" , "-DCMAKE_C_FLAGS=-DFOO=1 -DBAR=" ),
177175 ],
178176)
179- def test_passing_cxx_flags (monkeypatch , env_var , setting ):
177+ def test_passing_cxx_flags (monkeypatch , env_var , setting , tmp_path : Path ):
180178 # Note: This is sensitive to the types of quotes for SKBUILD_CMAKE_ARGS
181179 monkeypatch .setenv (env_var , setting )
182- build_wheel ("dist" , {"cmake.targets" : ["cmake_example" ]}) # Could leave empty
183- (wheel ,) = Path ("dist" ).glob ("cmake_example-0.0.1-py3-none-*.whl" )
180+ dist = tmp_path / "dist"
181+ build_wheel (str (dist ), {"cmake.targets" : ["cmake_example" ]}) # Could leave empty
182+ (wheel ,) = dist .glob ("cmake_example-0.0.1-py3-none-*.whl" )
184183 with zipfile .ZipFile (wheel ) as f :
185184 file_names = set (f .namelist ())
186185
@@ -198,9 +197,11 @@ def test_passing_cxx_flags(monkeypatch, env_var, setting):
198197@pytest .mark .compile
199198@pytest .mark .configure
200199@pytest .mark .usefixtures ("package_simple_pyproject_ext" )
201- def test_pep517_wheel (virtualenv ):
202- dist = Path ("dist" )
203- out = build_wheel ("dist" , {"cmake.targets" : ["cmake_example" ]}) # Could leave empty
200+ def test_pep517_wheel (virtualenv , tmp_path : Path ):
201+ dist = tmp_path / "dist"
202+ out = build_wheel (
203+ str (dist ), {"cmake.targets" : ["cmake_example" ]}
204+ ) # Could leave empty
204205 (wheel ,) = dist .glob ("cmake_example-0.0.1-*.whl" )
205206 assert wheel == dist / out
206207
@@ -248,9 +249,9 @@ def test_pep517_wheel(virtualenv):
248249@pytest .mark .compile
249250@pytest .mark .configure
250251@pytest .mark .usefixtures ("package_simple_pyproject_source_dir" )
251- def test_pep517_wheel_source_dir (virtualenv ):
252- dist = Path ( "dist" )
253- out = build_wheel (" dist" , config_settings = {"skbuild.wheel.build-tag" : "1foo" })
252+ def test_pep517_wheel_source_dir (virtualenv , tmp_path : Path ):
253+ dist = tmp_path / "dist"
254+ out = build_wheel (str ( dist ) , config_settings = {"skbuild.wheel.build-tag" : "1foo" })
254255 (wheel ,) = dist .glob ("cmake_example-0.0.1-*.whl" )
255256 assert wheel == dist / out
256257
@@ -306,18 +307,17 @@ def test_pep517_wheel_source_dir(virtualenv):
306307@pytest .mark .skip (reason = "Doesn't work yet" )
307308@pytest .mark .compile
308309@pytest .mark .configure
309- def test_pep517_wheel_time_hash (monkeypatch ):
310+ def test_pep517_wheel_time_hash (monkeypatch , tmp_path : Path ):
310311 monkeypatch .setenv ("SOURCE_DATE_EPOCH" , "12345" )
311- dist = Path ( "dist" )
312- out = build_wheel (" dist" )
312+ dist = tmp_path / "dist"
313+ out = build_wheel (str ( dist ) )
313314 wheel = dist / out
314315 hash1 = hashlib .sha256 (wheel .read_bytes ()).hexdigest ()
315316
316317 time .sleep (2 )
317318 Path ("src/main.cpp" ).touch ()
318319
319- if Path ("dist" ).is_dir ():
320- shutil .rmtree ("dist" )
320+ shutil .rmtree (dist )
321321
322322 out = build_wheel (str (dist ))
323323 wheel = dist / out
@@ -385,7 +385,7 @@ def test_pep639_license_files_metadata():
385385
386386
387387@pytest .mark .usefixtures ("package_pep639_pure" )
388- def test_pep639_license_files_sdist ():
388+ def test_pep639_license_files_sdist (tmp_path : Path ):
389389 expected_metadata = (
390390 inspect .cleandoc (
391391 """
@@ -400,8 +400,8 @@ def test_pep639_license_files_sdist():
400400 + "\n \n "
401401 )
402402
403- dist = Path ( "dist" )
404- out = build_sdist (" dist" )
403+ dist = tmp_path / "dist"
404+ out = build_sdist (str ( dist ) )
405405
406406 (sdist ,) = dist .iterdir ()
407407 assert sdist .name == "pep639_pure-0.1.0.tar.gz"
@@ -425,9 +425,9 @@ def test_pep639_license_files_sdist():
425425
426426
427427@pytest .mark .usefixtures ("package_pep639_pure" )
428- def test_pep639_license_files_wheel ():
429- dist = Path ( "dist" )
430- out = build_wheel (" dist" , {})
428+ def test_pep639_license_files_wheel (tmp_path : Path ):
429+ dist = tmp_path / "dist"
430+ out = build_wheel (str ( dist ) , {})
431431 (wheel ,) = dist .glob ("pep639_pure-0.1.0-*.whl" )
432432 assert wheel == dist / out
433433
0 commit comments