Skip to content

Commit 0877cbf

Browse files
committed
Black for utests
1 parent 891f1b2 commit 0877cbf

File tree

4 files changed

+209
-197
lines changed

4 files changed

+209
-197
lines changed

utest/test_get_keyword_source.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,87 @@
88
from DynamicTypesLibrary import DynamicTypesLibrary
99

1010

11-
@pytest.fixture(scope='module')
11+
@pytest.fixture(scope="module")
1212
def lib():
1313
return DynamicLibrary()
1414

1515

16-
@pytest.fixture(scope='module')
16+
@pytest.fixture(scope="module")
1717
def lib_types():
1818
return DynamicTypesLibrary()
1919

2020

21-
@pytest.fixture(scope='module')
21+
@pytest.fixture(scope="module")
2222
def cur_dir():
2323
return path.dirname(__file__)
2424

2525

26-
@pytest.fixture(scope='module')
26+
@pytest.fixture(scope="module")
2727
def lib_path(cur_dir):
28-
return path.normpath(path.join(cur_dir, '..', 'atest', 'DynamicLibrary.py'))
28+
return path.normpath(path.join(cur_dir, "..", "atest", "DynamicLibrary.py"))
2929

3030

31-
@pytest.fixture(scope='module')
31+
@pytest.fixture(scope="module")
3232
def lib_path_components(cur_dir):
33-
return path.normpath(path.join(cur_dir, '..', 'atest', 'librarycomponents.py'))
33+
return path.normpath(path.join(cur_dir, "..", "atest", "librarycomponents.py"))
3434

3535

36-
@pytest.fixture(scope='module')
36+
@pytest.fixture(scope="module")
3737
def lib_path_types(cur_dir):
38-
return path.normpath(path.join(cur_dir, '..', 'atest', 'DynamicTypesLibrary.py'))
38+
return path.normpath(path.join(cur_dir, "..", "atest", "DynamicTypesLibrary.py"))
3939

4040

4141
def test_location_in_main(lib, lib_path):
42-
source = lib.get_keyword_source('keyword_in_main')
43-
assert source == '%s:20' % lib_path
42+
source = lib.get_keyword_source("keyword_in_main")
43+
assert source == "%s:20" % lib_path
4444

4545

4646
def test_location_in_class(lib, lib_path_components):
47-
source = lib.get_keyword_source('method')
48-
assert source == '%s:13' % lib_path_components
47+
source = lib.get_keyword_source("method")
48+
assert source == "%s:13" % lib_path_components
4949

5050

5151
def test_decorator_wrapper(lib_types, lib_path_types):
52-
source = lib_types.get_keyword_source('keyword_wrapped')
53-
assert source == '%s:74' % lib_path_types
52+
source = lib_types.get_keyword_source("keyword_wrapped")
53+
assert source == "%s:74" % lib_path_types
5454

5555

5656
def test_location_in_class_custom_keyword_name(lib, lib_path_components):
57-
source = lib.get_keyword_source('Custom name')
58-
assert source == '%s:17' % lib_path_components
57+
source = lib.get_keyword_source("Custom name")
58+
assert source == "%s:17" % lib_path_components
5959

6060

6161
def test_no_line_number(lib, lib_path, when):
6262
when(lib)._DynamicCore__get_keyword_line(Any()).thenReturn(None)
63-
source = lib.get_keyword_source('keyword_in_main')
63+
source = lib.get_keyword_source("keyword_in_main")
6464
assert source == lib_path
6565

6666

6767
def test_no_path(lib, when):
6868
when(lib)._DynamicCore__get_keyword_path(Any()).thenReturn(None)
69-
source = lib.get_keyword_source('keyword_in_main')
70-
assert source == ':20'
69+
source = lib.get_keyword_source("keyword_in_main")
70+
assert source == ":20"
7171

7272

7373
def test_no_path_and_no_line_number(lib, when):
7474
when(lib)._DynamicCore__get_keyword_path(Any()).thenReturn(None)
7575
when(lib)._DynamicCore__get_keyword_line(Any()).thenReturn(None)
76-
source = lib.get_keyword_source('keyword_in_main')
76+
source = lib.get_keyword_source("keyword_in_main")
7777
assert source is None
7878

7979

8080
def test_def_in_decorator(lib_types, lib_path_types):
81-
source = lib_types.get_keyword_source('keyword_with_def_deco')
82-
assert source == '%s:68' % lib_path_types
81+
source = lib_types.get_keyword_source("keyword_with_def_deco")
82+
assert source == "%s:68" % lib_path_types
8383

8484

8585
def test_error_in_getfile(lib, when):
86-
when(inspect).getfile(Any()).thenRaise(TypeError('Some message'))
87-
source = lib.get_keyword_source('keyword_in_main')
86+
when(inspect).getfile(Any()).thenRaise(TypeError("Some message"))
87+
source = lib.get_keyword_source("keyword_in_main")
8888
assert source is None
8989

9090

9191
def test_error_in_line_number(lib, when, lib_path):
92-
when(inspect).getsourcelines(Any()).thenRaise(IOError('Some message'))
93-
source = lib.get_keyword_source('keyword_in_main')
92+
when(inspect).getsourcelines(Any()).thenRaise(IOError("Some message"))
93+
source = lib.get_keyword_source("keyword_in_main")
9494
assert source == lib_path

utest/test_get_keyword_types.py

+63-62
Original file line numberDiff line numberDiff line change
@@ -8,186 +8,187 @@
88
from DynamicTypesLibrary import DynamicTypesLibrary
99

1010

11-
@pytest.fixture(scope='module')
11+
@pytest.fixture(scope="module")
1212
def lib():
1313
return DynamicTypesLibrary()
1414

1515

16-
@pytest.fixture(scope='module')
16+
@pytest.fixture(scope="module")
1717
def lib_types():
18-
return DynamicTypesAnnotationsLibrary('aaa')
18+
return DynamicTypesAnnotationsLibrary("aaa")
1919

2020

2121
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}
2424

2525

2626
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")
2828
assert types is None
2929

3030

3131
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}
3434

3535

3636
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}
3939

4040

4141
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")
4343
assert types == {}
4444

4545

4646
def test_not_keyword(lib):
4747
with pytest.raises(ValueError):
48-
lib.get_keyword_types('not_keyword')
48+
lib.get_keyword_types("not_keyword")
4949

5050

5151
def test_keyword_none(lib):
52-
types = lib.get_keyword_types('keyword_none')
52+
types = lib.get_keyword_types("keyword_none")
5353
assert types == {}
5454

5555

5656
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}
5959

6060

6161
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}
6464

6565

6666
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]}
6969

7070

7171
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")
7373
assert len(types) == 1
74-
assert types['arg']
74+
assert types["arg"]
7575

7676

7777
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}
8080

8181

8282
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}
8585

8686

8787
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}
9090

9191

9292
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")
9494
assert types == {}
9595

9696

9797
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}
100100

101101

102102
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]}
105105

106106

107107
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}
110110

111111

112112
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")
114114
assert types is None
115115

116116

117117
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+
120121

121122
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}
124125

125126

126127
def test_dummy_magic_method(lib):
127128
with pytest.raises(ValueError):
128-
lib.get_keyword_types('__foobar__')
129+
lib.get_keyword_types("__foobar__")
129130

130131

131132
def test_varargs(lib):
132-
types = lib.get_keyword_types('varargs_and_kwargs')
133+
types = lib.get_keyword_types("varargs_and_kwargs")
133134
assert types == {}
134135

135136

136137
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}
139140

140141

141142
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"}
144145

145146

146147
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")
148149
assert types == {}
149150

150151

151152
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")
153154
assert types == {}
154155

155156

156157
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}
159160

160161

161162
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]}
164165

165166

166167
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")
168169
assert types == {}
169170

170171

171172
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}
174175

175176

176177
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}
179180

180181

181182
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}
184185

185186

186187
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)]}
189190

190191

191192
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

Comments
 (0)