@@ -45,9 +45,7 @@ def test_run_r_script( # noqa: PLR0913
45
45
@pytask.mark.r(script="script.r", serializer="{ serializer } ", suffix="{ suffix } ")
46
46
@pytask.mark.depends_on({ depends_on } )
47
47
@pytask.mark.produces("out.txt")
48
- def task_run_r_script():
49
- pass
50
-
48
+ def task_run_r_script(): ...
51
49
"""
52
50
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
53
51
tmp_path .joinpath ("in_1.txt" ).touch ()
@@ -77,14 +75,12 @@ def test_run_r_script_w_task_decorator(
77
75
runner , tmp_path , parse_config_code , serializer , suffix
78
76
):
79
77
task_source = f"""
80
- import pytask
81
-
82
- @pytask.mark.task
83
- @pytask.mark.r(script="script.r", serializer="{ serializer } ", suffix="{ suffix } ")
84
- @pytask.mark.produces("out.txt")
85
- def run_r_script():
86
- pass
78
+ from pytask import task, mark
87
79
80
+ @task
81
+ @mark.r(script="script.r", serializer="{ serializer } ", suffix="{ suffix } ")
82
+ @mark.produces("out.txt")
83
+ def run_r_script(): ...
88
84
"""
89
85
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
90
86
@@ -113,8 +109,7 @@ def test_raise_error_if_rscript_is_not_found(
113
109
114
110
@pytask.mark.r(script="script.r", serializer="{ serializer } ", suffix="{ suffix } ")
115
111
@pytask.mark.produces("out.txt")
116
- def task_run_r_script():
117
- pass
112
+ def task_run_r_script(): ...
118
113
"""
119
114
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
120
115
@@ -152,8 +147,7 @@ def test_run_r_script_w_saving_workspace(
152
147
suffix="{ suffix } "
153
148
)
154
149
@pytask.mark.produces("out.txt")
155
- def task_run_r_script():
156
- pass
150
+ def task_run_r_script(): ...
157
151
"""
158
152
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
159
153
@@ -188,8 +182,7 @@ def test_run_r_script_w_wrong_cmd_option(
188
182
suffix="{ suffix } "
189
183
)
190
184
@pytask.mark.produces("out.txt")
191
- def task_run_r_script():
192
- pass
185
+ def task_run_r_script(): ...
193
186
"""
194
187
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
195
188
@@ -216,8 +209,7 @@ def test_run_r_script_w_custom_serializer(runner, tmp_path):
216
209
217
210
@pytask.mark.r(script="script.r", serializer=json.dumps, suffix=".json")
218
211
@pytask.mark.produces("out.txt")
219
- def task_run_r_script():
220
- pass
212
+ def task_run_r_script(): ...
221
213
222
214
"""
223
215
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
@@ -247,8 +239,7 @@ def test_run_r_script_fails_w_multiple_markers(runner, tmp_path):
247
239
@pytask.mark.r(script="script.r")
248
240
@pytask.mark.r(script="script.r")
249
241
@pytask.mark.produces("out.txt")
250
- def task_run_r_script():
251
- pass
242
+ def task_run_r_script(): ...
252
243
"""
253
244
tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
254
245
tmp_path .joinpath ("script.r" ).touch ()
@@ -257,3 +248,31 @@ def task_run_r_script():
257
248
258
249
assert result .exit_code == ExitCode .COLLECTION_FAILED
259
250
assert "has multiple @pytask.mark.r marks" in result .output
251
+
252
+
253
+ @needs_rscript
254
+ @pytest .mark .end_to_end ()
255
+ def test_run_r_script_with_capital_extension (runner , tmp_path ):
256
+ task_source = """
257
+ import pytask
258
+
259
+ @pytask.mark.r(script="script.R")
260
+ @pytask.mark.produces("out.txt")
261
+ def task_run_r_script(): ...
262
+ """
263
+ tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (task_source ))
264
+
265
+ r_script = """
266
+ library(jsonlite)
267
+ args <- commandArgs(trailingOnly=TRUE)
268
+ config <- read_json(args[length(args)])
269
+ file_descriptor <- file(config$produces)
270
+ writeLines(c("So, so you think you can tell heaven from hell?"), file_descriptor)
271
+ close(file_descriptor)
272
+ """
273
+ tmp_path .joinpath ("script.R" ).write_text (textwrap .dedent (r_script ))
274
+
275
+ result = runner .invoke (cli , [tmp_path .as_posix ()])
276
+
277
+ assert result .exit_code == ExitCode .OK
278
+ assert tmp_path .joinpath ("out.txt" ).exists ()
0 commit comments