|
8 | 8 | from DynamicTypesLibrary import DynamicTypesLibrary
|
9 | 9 |
|
10 | 10 |
|
11 |
| -@pytest.fixture(scope='module') |
| 11 | +@pytest.fixture(scope="module") |
12 | 12 | def lib():
|
13 | 13 | return DynamicTypesLibrary()
|
14 | 14 |
|
15 | 15 |
|
16 |
| -@pytest.fixture(scope='module') |
| 16 | +@pytest.fixture(scope="module") |
17 | 17 | def lib_types():
|
18 |
| - return DynamicTypesAnnotationsLibrary('aaa') |
| 18 | + return DynamicTypesAnnotationsLibrary("aaa") |
19 | 19 |
|
20 | 20 |
|
21 | 21 | def test_using_keyword_types(lib):
|
22 |
| - types = lib.get_keyword_types('keyword_with_types') |
23 |
| - assert types == {'arg1': str} |
| 22 | + types = lib.get_keyword_types("keyword_with_types") |
| 23 | + assert types == {"arg1": str} |
24 | 24 |
|
25 | 25 |
|
26 | 26 | def test_types_disabled(lib):
|
27 |
| - types = lib.get_keyword_types('keyword_with_disabled_types') |
| 27 | + types = lib.get_keyword_types("keyword_with_disabled_types") |
28 | 28 | assert types is None
|
29 | 29 |
|
30 | 30 |
|
31 | 31 | def test_keyword_types_and_bool_default(lib):
|
32 |
| - types = lib.get_keyword_types('keyword_robot_types_and_bool_default') |
33 |
| - assert types == {'arg1': str} |
| 32 | + types = lib.get_keyword_types("keyword_robot_types_and_bool_default") |
| 33 | + assert types == {"arg1": str} |
34 | 34 |
|
35 | 35 |
|
36 | 36 | def test_one_keyword_type_defined(lib):
|
37 |
| - types = lib.get_keyword_types('keyword_with_one_type') |
38 |
| - assert types == {'arg1': str} |
| 37 | + types = lib.get_keyword_types("keyword_with_one_type") |
| 38 | + assert types == {"arg1": str} |
39 | 39 |
|
40 | 40 |
|
41 | 41 | def test_keyword_no_args(lib):
|
42 |
| - types = lib.get_keyword_types('keyword_with_no_args') |
| 42 | + types = lib.get_keyword_types("keyword_with_no_args") |
43 | 43 | assert types == {}
|
44 | 44 |
|
45 | 45 |
|
46 | 46 | def test_not_keyword(lib):
|
47 | 47 | with pytest.raises(ValueError):
|
48 |
| - lib.get_keyword_types('not_keyword') |
| 48 | + lib.get_keyword_types("not_keyword") |
49 | 49 |
|
50 | 50 |
|
51 | 51 | def test_keyword_none(lib):
|
52 |
| - types = lib.get_keyword_types('keyword_none') |
| 52 | + types = lib.get_keyword_types("keyword_none") |
53 | 53 | assert types == {}
|
54 | 54 |
|
55 | 55 |
|
56 | 56 | def test_single_annotation(lib_types):
|
57 |
| - types = lib_types.get_keyword_types('keyword_with_one_annotation') |
58 |
| - assert types == {'arg': str} |
| 57 | + types = lib_types.get_keyword_types("keyword_with_one_annotation") |
| 58 | + assert types == {"arg": str} |
59 | 59 |
|
60 | 60 |
|
61 | 61 | def test_multiple_annotations(lib_types):
|
62 |
| - types = lib_types.get_keyword_types('keyword_with_multiple_annotations') |
63 |
| - assert types == {'arg1': str, 'arg2': List} |
| 62 | + types = lib_types.get_keyword_types("keyword_with_multiple_annotations") |
| 63 | + assert types == {"arg1": str, "arg2": List} |
64 | 64 |
|
65 | 65 |
|
66 | 66 | def test_multiple_types(lib_types):
|
67 |
| - types = lib_types.get_keyword_types('keyword_multiple_types') |
68 |
| - assert types == {'arg': Union[List, None]} |
| 67 | + types = lib_types.get_keyword_types("keyword_multiple_types") |
| 68 | + assert types == {"arg": Union[List, None]} |
69 | 69 |
|
70 | 70 |
|
71 | 71 | def test_keyword_new_type(lib_types):
|
72 |
| - types = lib_types.get_keyword_types('keyword_new_type') |
| 72 | + types = lib_types.get_keyword_types("keyword_new_type") |
73 | 73 | assert len(types) == 1
|
74 |
| - assert types['arg'] |
| 74 | + assert types["arg"] |
75 | 75 |
|
76 | 76 |
|
77 | 77 | def test_keyword_return_type(lib_types):
|
78 |
| - types = lib_types.get_keyword_types('keyword_define_return_type') |
79 |
| - assert types == {'arg': str} |
| 78 | + types = lib_types.get_keyword_types("keyword_define_return_type") |
| 79 | + assert types == {"arg": str} |
80 | 80 |
|
81 | 81 |
|
82 | 82 | def test_keyword_forward_references(lib_types):
|
83 |
| - types = lib_types.get_keyword_types('keyword_forward_references') |
84 |
| - assert types == {'arg': CustomObject} |
| 83 | + types = lib_types.get_keyword_types("keyword_forward_references") |
| 84 | + assert types == {"arg": CustomObject} |
85 | 85 |
|
86 | 86 |
|
87 | 87 | def test_keyword_with_annotation_and_default(lib_types):
|
88 |
| - types = lib_types.get_keyword_types('keyword_with_annotations_and_default') |
89 |
| - assert types == {'arg': str} |
| 88 | + types = lib_types.get_keyword_types("keyword_with_annotations_and_default") |
| 89 | + assert types == {"arg": str} |
90 | 90 |
|
91 | 91 |
|
92 | 92 | def test_keyword_with_many_defaults(lib):
|
93 |
| - types = lib.get_keyword_types('keyword_many_default_types') |
| 93 | + types = lib.get_keyword_types("keyword_many_default_types") |
94 | 94 | assert types == {}
|
95 | 95 |
|
96 | 96 |
|
97 | 97 | def test_keyword_with_annotation_external_class(lib_types):
|
98 |
| - types = lib_types.get_keyword_types('keyword_with_webdriver') |
99 |
| - assert types == {'arg': CustomObject} |
| 98 | + types = lib_types.get_keyword_types("keyword_with_webdriver") |
| 99 | + assert types == {"arg": CustomObject} |
100 | 100 |
|
101 | 101 |
|
102 | 102 | def test_keyword_with_annotation_and_default_part2(lib_types):
|
103 |
| - types = lib_types.get_keyword_types('keyword_default_and_annotation') |
104 |
| - assert types == {'arg1': int, 'arg2': Union[bool, str]} |
| 103 | + types = lib_types.get_keyword_types("keyword_default_and_annotation") |
| 104 | + assert types == {"arg1": int, "arg2": Union[bool, str]} |
105 | 105 |
|
106 | 106 |
|
107 | 107 | def test_keyword_with_robot_types_and_annotations(lib_types):
|
108 |
| - types = lib_types.get_keyword_types('keyword_robot_types_and_annotations') |
109 |
| - assert types == {'arg': str} |
| 108 | + types = lib_types.get_keyword_types("keyword_robot_types_and_annotations") |
| 109 | + assert types == {"arg": str} |
110 | 110 |
|
111 | 111 |
|
112 | 112 | def test_keyword_with_robot_types_disbaled_and_annotations(lib_types):
|
113 |
| - types = lib_types.get_keyword_types('keyword_robot_types_disabled_and_annotations') |
| 113 | + types = lib_types.get_keyword_types("keyword_robot_types_disabled_and_annotations") |
114 | 114 | assert types is None
|
115 | 115 |
|
116 | 116 |
|
117 | 117 | def test_keyword_with_robot_types_and_bool_annotations(lib_types):
|
118 |
| - types = lib_types.get_keyword_types('keyword_robot_types_and_bool_hint') |
119 |
| - assert types == {'arg1': str} |
| 118 | + types = lib_types.get_keyword_types("keyword_robot_types_and_bool_hint") |
| 119 | + assert types == {"arg1": str} |
| 120 | + |
120 | 121 |
|
121 | 122 | def test_init_args(lib_types):
|
122 |
| - types = lib_types.get_keyword_types('__init__') |
123 |
| - assert types == {'arg': str} |
| 123 | + types = lib_types.get_keyword_types("__init__") |
| 124 | + assert types == {"arg": str} |
124 | 125 |
|
125 | 126 |
|
126 | 127 | def test_dummy_magic_method(lib):
|
127 | 128 | with pytest.raises(ValueError):
|
128 |
| - lib.get_keyword_types('__foobar__') |
| 129 | + lib.get_keyword_types("__foobar__") |
129 | 130 |
|
130 | 131 |
|
131 | 132 | def test_varargs(lib):
|
132 |
| - types = lib.get_keyword_types('varargs_and_kwargs') |
| 133 | + types = lib.get_keyword_types("varargs_and_kwargs") |
133 | 134 | assert types == {}
|
134 | 135 |
|
135 | 136 |
|
136 | 137 | def test_init_args_with_annotation(lib_types):
|
137 |
| - types = lib_types.get_keyword_types('__init__') |
138 |
| - assert types == {'arg': str} |
| 138 | + types = lib_types.get_keyword_types("__init__") |
| 139 | + assert types == {"arg": str} |
139 | 140 |
|
140 | 141 |
|
141 | 142 | def test_exception_in_annotations(lib_types):
|
142 |
| - types = lib_types.get_keyword_types('keyword_exception_annotations') |
143 |
| - assert types == {'arg': 'NotHere'} |
| 143 | + types = lib_types.get_keyword_types("keyword_exception_annotations") |
| 144 | + assert types == {"arg": "NotHere"} |
144 | 145 |
|
145 | 146 |
|
146 | 147 | def test_keyword_only_arguments(lib_types):
|
147 |
| - types = lib_types.get_keyword_types('keyword_only_arguments') |
| 148 | + types = lib_types.get_keyword_types("keyword_only_arguments") |
148 | 149 | assert types == {}
|
149 | 150 |
|
150 | 151 |
|
151 | 152 | def test_keyword_only_arguments_many(lib_types):
|
152 |
| - types = lib_types.get_keyword_types('keyword_only_arguments_many') |
| 153 | + types = lib_types.get_keyword_types("keyword_only_arguments_many") |
153 | 154 | assert types == {}
|
154 | 155 |
|
155 | 156 |
|
156 | 157 | def test_keyword_mandatory_and_keyword_only_arguments(lib_types):
|
157 |
| - types = lib_types.get_keyword_types('keyword_mandatory_and_keyword_only_arguments') |
158 |
| - assert types == {'arg': int, 'some': bool} |
| 158 | + types = lib_types.get_keyword_types("keyword_mandatory_and_keyword_only_arguments") |
| 159 | + assert types == {"arg": int, "some": bool} |
159 | 160 |
|
160 | 161 |
|
161 | 162 | def test_keyword_only_arguments_many_positional_and_default(lib_types):
|
162 |
| - types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default') |
163 |
| - assert types == {'four': Union[int, str], 'six': Union[bool, str]} |
| 163 | + types = lib_types.get_keyword_types("keyword_only_arguments_many_positional_and_default") |
| 164 | + assert types == {"four": Union[int, str], "six": Union[bool, str]} |
164 | 165 |
|
165 | 166 |
|
166 | 167 | def test_keyword_all_args(lib_types):
|
167 |
| - types = lib_types.get_keyword_types('keyword_all_args') |
| 168 | + types = lib_types.get_keyword_types("keyword_all_args") |
168 | 169 | assert types == {}
|
169 | 170 |
|
170 | 171 |
|
171 | 172 | def test_keyword_self_and_types(lib_types):
|
172 |
| - types = lib_types.get_keyword_types('keyword_self_and_types') |
173 |
| - assert types == {'mandatory': str, 'other': bool} |
| 173 | + types = lib_types.get_keyword_types("keyword_self_and_types") |
| 174 | + assert types == {"mandatory": str, "other": bool} |
174 | 175 |
|
175 | 176 |
|
176 | 177 | def test_keyword_self_and_keyword_only_types(lib_types):
|
177 |
| - types = lib_types.get_keyword_types('keyword_self_and_keyword_only_types') |
178 |
| - assert types == {'varargs': int, 'other': bool, 'kwargs': int} |
| 178 | + types = lib_types.get_keyword_types("keyword_self_and_keyword_only_types") |
| 179 | + assert types == {"varargs": int, "other": bool, "kwargs": int} |
179 | 180 |
|
180 | 181 |
|
181 | 182 | def test_keyword_with_decorator_arguments(lib_types):
|
182 |
| - types = lib_types.get_keyword_types('keyword_with_deco_and_signature') |
183 |
| - assert types == {'arg1': bool, 'arg2': bool} |
| 183 | + types = lib_types.get_keyword_types("keyword_with_deco_and_signature") |
| 184 | + assert types == {"arg1": bool, "arg2": bool} |
184 | 185 |
|
185 | 186 |
|
186 | 187 | def test_keyword_optional_with_none(lib_types):
|
187 |
| - types = lib_types.get_keyword_types('keyword_optional_with_none') |
188 |
| - assert types == {'arg': typing.Union[str, type(None)]} |
| 188 | + types = lib_types.get_keyword_types("keyword_optional_with_none") |
| 189 | + assert types == {"arg": typing.Union[str, type(None)]} |
189 | 190 |
|
190 | 191 |
|
191 | 192 | def test_keyword_union_with_none(lib_types):
|
192 |
| - types = lib_types.get_keyword_types('keyword_union_with_none') |
193 |
| - assert types == {'arg': typing.Union[type(None), typing.Dict, str]} |
| 193 | + types = lib_types.get_keyword_types("keyword_union_with_none") |
| 194 | + assert types == {"arg": typing.Union[type(None), typing.Dict, str]} |
0 commit comments