1010from tests .conftest import run_in_subprocess
1111
1212
13- @pytest .mark .parametrize ("module_name " , [True , False ])
14- def test_add_new_hook_via_cli (tmp_path , module_name ):
13+ @pytest .mark .parametrize ("hook_location " , ["hooks/hooks.py" , "hooks.hooks" ])
14+ def test_add_new_hook_via_cli (tmp_path , hook_location ):
1515 hooks = """
1616 import click
1717 from pytask import hookimpl
@@ -24,36 +24,24 @@ def pytask_extend_command_line_interface(cli):
2424 tmp_path .joinpath ("hooks" ).mkdir ()
2525 tmp_path .joinpath ("hooks" , "hooks.py" ).write_text (textwrap .dedent (hooks ))
2626
27- if module_name :
28- args = (
29- sys .executable ,
30- "-m" ,
31- "pytask" ,
32- "build" ,
33- "--hook-module" ,
34- "hooks.hooks" ,
35- "--help" ,
36- )
37- else :
38- args = (
39- "uv" ,
40- "run" ,
41- "pytask" ,
42- "build" ,
43- "--hook-module" ,
44- "hooks/hooks.py" ,
45- "--help" ,
46- )
47-
27+ args = (
28+ sys .executable ,
29+ "-m" ,
30+ "pytask" ,
31+ "build" ,
32+ "--hook-module" ,
33+ hook_location ,
34+ "--help" ,
35+ )
4836 result = run_in_subprocess (args , cwd = tmp_path )
4937 assert result .exit_code == ExitCode .OK
5038 assert "--new-option" in result .stdout
5139
5240
53- @pytest .mark .parametrize ("module_name " , [True , False ])
54- def test_add_new_hook_via_config (tmp_path , module_name ):
41+ @pytest .mark .parametrize ("hook_location " , ["hooks/hooks.py" , "hooks.hooks" ])
42+ def test_add_new_hook_via_config (tmp_path , hook_location ):
5543 tmp_path .joinpath ("pyproject.toml" ).write_text (
56- "[tool.pytask.ini_options]\n hook_module = ['hooks/hooks.py ']"
44+ f "[tool.pytask.ini_options]\n hook_module = ['{ hook_location } ']"
5745 )
5846
5947 hooks = """
@@ -67,16 +55,7 @@ def pytask_extend_command_line_interface(cli):
6755 tmp_path .joinpath ("hooks" ).mkdir ()
6856 tmp_path .joinpath ("hooks" , "hooks.py" ).write_text (textwrap .dedent (hooks ))
6957
70- if module_name :
71- args = (
72- sys .executable ,
73- "-m" ,
74- "pytask" ,
75- "build" ,
76- "--help" ,
77- )
78- else :
79- args = ("uv" , "run" , "--no-project" , "pytask" , "build" , "--help" )
58+ args = (sys .executable , "-m" , "pytask" , "build" , "--help" )
8059
8160 result = run_in_subprocess (args , cwd = tmp_path )
8261 assert result .exit_code == ExitCode .OK
0 commit comments