forked from kljohann/genpybind-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotations_unit_test.py
43 lines (35 loc) · 1.37 KB
/
annotations_unit_test.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
import pytest
from genpybind.annotations import Annotations
def as_list(inp):
return list(Annotations(inp))
def test_example():
inp = "plain, call(), with_arg(some_name), with_args(a, b, c, 1, 2, 3, 'hello', \"world\")"
assert as_list(inp) == [
("plain", ()),
("call", ()),
("with_arg", ("some_name",)),
("with_args", ("a", "b", "c", 1, 2, 3, "hello", "world")),
]
def test_plain():
assert as_list("plain") == [("plain", ())]
def test_multiple():
assert as_list(["multiple", "attributes(are, supported)"]) == [
("multiple", ()),
("attributes", ("are", "supported"))
]
def test_special_names():
assert as_list("required(true), visible(false), whatever(default), none(none)") == [
("required", (True,)),
("visible", (False,)),
("whatever", (None,)),
("none", (None,)),
]
@pytest.mark.parametrize("spelling", ["true", "True"])
def test_special_true(spelling):
assert as_list("value({})".format(spelling)) == [("value", (True,))]
@pytest.mark.parametrize("spelling", ["false", "False"])
def test_special_false(spelling):
assert as_list("value({})".format(spelling)) == [("value", (False,))]
@pytest.mark.parametrize("spelling", ["none", "None", "default", "Default"])
def test_special_none(spelling):
assert as_list("value({})".format(spelling)) == [("value", (None,))]