-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathtest_helpers.py
80 lines (57 loc) · 2.05 KB
/
test_helpers.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from __future__ import annotations
from cleo.helpers import argument
from cleo.helpers import option
def test_argument() -> None:
arg = argument("foo", "Foo")
assert arg.description == "Foo"
assert arg.is_required()
assert not arg.is_list()
assert arg.default is None
arg = argument("foo", "Foo", optional=True, default="bar")
assert not arg.is_required()
assert not arg.is_list()
assert arg.default == "bar"
arg = argument("foo", "Foo", multiple=True)
assert arg.is_required()
assert arg.is_list()
assert arg.default == []
arg = argument("foo", "Foo", optional=True, multiple=True, default=["bar"])
assert not arg.is_required()
assert arg.is_list()
assert arg.default == ["bar"]
def test_option() -> None:
opt = option("foo", "f", "Foo")
assert opt.description == "Foo"
assert not opt.accepts_value()
assert not opt.requires_value()
assert not opt.is_list()
assert opt.default is False
opt = option("foo", "f", "Foo", flag=False)
assert opt.description == "Foo"
assert opt.accepts_value()
assert opt.requires_value()
assert not opt.is_list()
assert opt.default is None
opt = option("foo", "f", "Foo", flag=False, value_required=False)
assert opt.description == "Foo"
assert opt.accepts_value()
assert not opt.requires_value()
assert not opt.is_list()
opt = option("foo", "f", "Foo", flag=False, multiple=True)
assert opt.description == "Foo"
assert opt.accepts_value()
assert opt.requires_value()
assert opt.is_list()
assert opt.default == []
opt = option("foo", "f", "Foo", flag=False, default="bar")
assert opt.description == "Foo"
assert opt.accepts_value()
assert opt.requires_value()
assert not opt.is_list()
assert opt.default == "bar"
opt = option("foo", "f", "Foo", flag=False, choices=["bar1", "bar2"])
assert opt.description == "Foo"
assert opt.accepts_value()
assert opt.requires_value()
assert not opt.is_list()
assert opt.choices == ["bar1", "bar2"]