@@ -193,29 +193,58 @@ def test_run_without_requirements(caplog, pipx_temp_env, tmp_path):
193193
194194
195195@mock .patch ("os.execvpe" , new = execvpe_mock )
196- def test_run_with_requirements (caplog , pipx_temp_env , tmp_path ):
196+ @pytest .mark .parametrize (
197+ "script_text, expected_output" ,
198+ [
199+ pytest .param (
200+ """
201+ # /// script
202+ # dependencies = []
203+ # ///
204+ from pathlib import Path
205+ Path({out!r}).write_text("explicit-empty")
206+ """ ,
207+ "explicit-empty" ,
208+ id = "explicit-empty-dependencies" ,
209+ ),
210+ pytest .param (
211+ """
212+ # /// script
213+ # ///
214+ from pathlib import Path
215+ Path({out!r}).write_text("implicit-empty")
216+ """ ,
217+ "implicit-empty" ,
218+ id = "implicit-empty-dependencies" ,
219+ ),
220+ pytest .param (
221+ """
222+ # /// script
223+ # dependencies = ["requests==2.31.0"]
224+ # ///
225+
226+ # Check requests can be imported
227+ import requests
228+ # Check dependencies of requests can be imported
229+ import certifi
230+ # Check the installed version
231+ from pathlib import Path
232+ Path({out!r}).write_text(requests.__version__)
233+ """ ,
234+ "2.31.0" ,
235+ id = "non-empty-dependencies" ,
236+ ),
237+ ],
238+ )
239+ def test_run_with_requirements (script_text , expected_output , caplog , pipx_temp_env , tmp_path ):
197240 script = tmp_path / "test.py"
198241 out = tmp_path / "output.txt"
199242 script .write_text (
200- textwrap .dedent (
201- f"""
202- # /// script
203- # dependencies = ["requests==2.31.0"]
204- # ///
205-
206- # Check requests can be imported
207- import requests
208- # Check dependencies of requests can be imported
209- import certifi
210- # Check the installed version
211- from pathlib import Path
212- Path({ str (out )!r} ).write_text(requests.__version__)
213- """
214- ).strip (),
243+ textwrap .dedent (script_text .format (out = str (out ))).strip (),
215244 encoding = "utf-8" ,
216245 )
217246 run_pipx_cli_exit (["run" , script .as_uri ()])
218- assert out .read_text () == "2.31.0"
247+ assert out .read_text () == expected_output
219248
220249
221250@mock .patch ("os.execvpe" , new = execvpe_mock )
0 commit comments