@@ -16,27 +16,18 @@ def _test_r_parsing(
1616 tempdir_factory ,
1717 store ,
1818 hook_id ,
19- expected_hook_expr = {},
20- expected_args = {},
21- config = {},
22- expect_path_prefix = True ,
19+ expected_hook_expr = (),
20+ expected_args = (),
21+ config = None ,
2322):
24- repo_path = 'r_hooks_repo'
25- path = make_repo (tempdir_factory , repo_path )
26- config = config or make_config_from_repo (path )
23+ repo = make_repo (tempdir_factory , 'r_hooks_repo' )
24+ config = make_config_from_repo (repo )
2725 hook = _get_hook_no_install (config , store , hook_id )
2826 ret = r ._cmd_from_hook (hook )
29- expected_cmd = 'Rscript'
30- expected_opts = (
31- '--no-save' , '--no-restore' , '--no-site-file' , '--no-environ' ,
32- )
33- expected_path = os .path .join (
34- hook .prefix .prefix_dir if expect_path_prefix else '' ,
35- f'{ hook_id } .R' ,
36- )
27+ expected_path = os .path .join (hook .prefix .prefix_dir , f'{ hook_id } .R' )
3728 expected = (
38- expected_cmd ,
39- * expected_opts ,
29+ 'Rscript' ,
30+ '--no-save' , '--no-restore' , '--no-site-file' , '--no-environ' ,
4031 * (expected_hook_expr or (expected_path ,)),
4132 * expected_args ,
4233 )
@@ -84,9 +75,7 @@ def test_r_parsing_expr_no_opts_no_args2(tempdir_factory, store):
8475def test_r_parsing_expr_opts_no_args2 (tempdir_factory , store ):
8576 with pytest .raises (ValueError ) as execinfo :
8677 r ._entry_validate (
87- [
88- 'Rscript' , '--vanilla' , '-e' , '1+1' , '-e' , 'letters' ,
89- ],
78+ ['Rscript' , '--vanilla' , '-e' , '1+1' , '-e' , 'letters' ],
9079 )
9180 msg = execinfo .value .args
9281 assert msg == (
@@ -112,24 +101,21 @@ def test_r_parsing_expr_non_Rscirpt(tempdir_factory, store):
112101
113102
114103def test_r_parsing_file_local (tempdir_factory , store ):
115- path = 'path/to/script.R'
116- hook_id = 'local-r'
117104 config = {
118105 'repo' : 'local' ,
119106 'hooks' : [{
120- 'id' : hook_id ,
107+ 'id' : 'local-r' ,
121108 'name' : 'local-r' ,
122- 'entry' : f 'Rscript { path } ' ,
109+ 'entry' : 'Rscript path/to/script.R ' ,
123110 'language' : 'r' ,
124111 }],
125112 }
126- _test_r_parsing (
127- tempdir_factory ,
128- store ,
129- hook_id = hook_id ,
130- expected_hook_expr = (path ,),
131- config = config ,
132- expect_path_prefix = False ,
113+ hook = _get_hook_no_install (config , store , 'local-r' )
114+ ret = r ._cmd_from_hook (hook )
115+ assert ret == (
116+ 'Rscript' ,
117+ '--no-save' , '--no-restore' , '--no-site-file' , '--no-environ' ,
118+ hook .prefix .path ('path/to/script.R' ),
133119 )
134120
135121
0 commit comments