-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_collect.py
54 lines (47 loc) · 1.23 KB
/
test_collect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from __future__ import annotations
from contextlib import ExitStack as does_not_raise # noqa: N813
import pytest
from pytask import Mark
from pytask_stata.collect import _parse_stata_mark
from pytask_stata.collect import stata
@pytest.mark.unit
@pytest.mark.parametrize(
("args", "kwargs", "expectation", "expected"),
[
(
(),
{"script": "script.do", "options": "--option"},
does_not_raise(),
("script.do", ["--option"]),
),
(
(),
{"script": "script.do", "options": [1]},
does_not_raise(),
("script.do", ["1"]),
),
],
)
def test_stata(args, kwargs, expectation, expected):
with expectation:
options = stata(*args, **kwargs)
assert options == expected
@pytest.mark.unit
@pytest.mark.parametrize(
("mark", "expectation", "expected"),
[
(
Mark("stata", (), {"script": "script.do"}),
does_not_raise(),
Mark("stata", (), {"script": "script.do", "options": []}),
),
],
)
def test_parse_stata_mark(
mark,
expectation,
expected,
):
with expectation:
out = _parse_stata_mark(mark)
assert out == expected