Skip to content

Commit bd21af1

Browse files
hugovkaaltat
authored andcommitted
Drop support for EOL Python 2.7
1 parent 8d1e08f commit bd21af1

File tree

6 files changed

+11
-81
lines changed

6 files changed

+11
-81
lines changed

atest/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
sys.exit(rc)
2727
process_output(output, verbose=False)
2828
output = join(outdir, 'lib-DynamicTypesLibrary-python-%s-robot-%s.xml' % (python_version, rf_version))
29-
exclude = 'py3' if sys.version_info < (3,) else ''
30-
rc = run(tests_types, name='Types', output=output, report=None, log=None, loglevel='debug', exclude=exclude)
29+
rc = run(tests_types, name='Types', output=output, report=None, log=None, loglevel='debug')
3130
if rc > 250:
3231
sys.exit(rc)
3332
process_output(output, verbose=False)

src/robotlibcore.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import inspect
2323
import os
24-
import sys
2524

2625
from robot.utils import PY_VERSION
2726

@@ -33,7 +32,6 @@
3332
from robot.api.deco import keyword # noqa F401
3433
from robot import __version__ as robot_version
3534

36-
PY2 = sys.version_info < (3,)
3735
RF31 = robot_version < '3.2'
3836

3937
__version__ = '2.2.2.dev1'
@@ -87,10 +85,7 @@ def __getattr__(self, name):
8785
.format(type(self).__name__, name))
8886

8987
def __dir__(self):
90-
if PY2:
91-
my_attrs = dir(type(self)) + list(self.__dict__)
92-
else:
93-
my_attrs = super().__dir__()
88+
my_attrs = super().__dir__()
9489
return sorted(set(my_attrs) | set(self.attributes))
9590

9691
def get_keyword_names(self):
@@ -172,8 +167,6 @@ def build(cls, function):
172167

173168
@classmethod
174169
def unwrap(cls, function):
175-
if PY2:
176-
return function
177170
return inspect.unwrap(function)
178171

179172
@classmethod
@@ -192,8 +185,6 @@ def _get_arguments(cls, function):
192185

193186
@classmethod
194187
def _get_arg_spec(cls, function):
195-
if PY2:
196-
return inspect.getargspec(function)
197188
return inspect.getfullargspec(function)
198189

199190
@classmethod
@@ -224,15 +215,11 @@ def _get_var_args(cls, arg_spec):
224215

225216
@classmethod
226217
def _get_kwargs(cls, arg_spec):
227-
if PY2:
228-
return ['**%s' % arg_spec.keywords] if arg_spec.keywords else []
229218
return ['**%s' % arg_spec.varkw] if arg_spec.varkw else []
230219

231220
@classmethod
232221
def _get_kw_only(cls, arg_spec):
233222
kw_only_args = []
234-
if PY2:
235-
return kw_only_args
236223
for arg in arg_spec.kwonlyargs:
237224
if not arg_spec.kwonlydefaults or arg not in arg_spec.kwonlydefaults:
238225
kw_only_args.append(arg)
@@ -258,8 +245,6 @@ def _get_types(cls, function):
258245

259246
@classmethod
260247
def _get_typing_hints(cls, function):
261-
if PY2:
262-
return {}
263248
function = cls.unwrap(function)
264249
try:
265250
hints = typing.get_type_hints(function)

utest/test_get_keyword_source.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from DynamicLibrary import DynamicLibrary
88
from DynamicTypesLibrary import DynamicTypesLibrary
9-
from robotlibcore import PY2
109

1110

1211
@pytest.fixture(scope='module')
@@ -49,7 +48,6 @@ def test_location_in_class(lib, lib_path_components):
4948
assert source == '%s:15' % lib_path_components
5049

5150

52-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
5351
def test_decorator_wrapper(lib_types, lib_path_types):
5452
source = lib_types.get_keyword_source('keyword_wrapped')
5553
assert source == '%s:72' % lib_path_types

utest/test_get_keyword_types.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import pytest
22

33

4-
from robotlibcore import PY2, RF31
5-
6-
if not PY2:
7-
from typing import List, Union, Dict
8-
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
9-
from DynamicTypesAnnotationsLibrary import CustomObject
4+
from robotlibcore import RF31
105

6+
from typing import List, Union
7+
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
8+
from DynamicTypesAnnotationsLibrary import CustomObject
119
from DynamicTypesLibrary import DynamicTypesLibrary
1210

1311

@@ -70,44 +68,37 @@ def test_keyword_none_rf31(lib):
7068
assert types == {}
7169

7270

73-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
7471
def test_single_annotation(lib_types):
7572
types = lib_types.get_keyword_types('keyword_with_one_annotation')
7673
assert types == {'arg': str}
7774

7875

79-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
8076
def test_multiple_annotations(lib_types):
8177
types = lib_types.get_keyword_types('keyword_with_multiple_annotations')
8278
assert types == {'arg1': str, 'arg2': List}
8379

8480

85-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
8681
def test_multiple_types(lib_types):
8782
types = lib_types.get_keyword_types('keyword_multiple_types')
8883
assert types == {'arg': Union[List, None]}
8984

9085

91-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
9286
def test_keyword_new_type(lib_types):
9387
types = lib_types.get_keyword_types('keyword_new_type')
9488
assert len(types) == 1
9589
assert types['arg']
9690

9791

98-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
9992
def test_keyword_return_type(lib_types):
10093
types = lib_types.get_keyword_types('keyword_define_return_type')
10194
assert types == {'arg': str}
10295

10396

104-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
10597
def test_keyword_forward_references(lib_types):
10698
types = lib_types.get_keyword_types('keyword_forward_references')
10799
assert types == {'arg': CustomObject}
108100

109101

110-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
111102
def test_keyword_with_annotation_and_default(lib_types):
112103
types = lib_types.get_keyword_types('keyword_with_annotations_and_default')
113104
assert types == {'arg': str}
@@ -118,36 +109,30 @@ def test_keyword_with_many_defaults(lib):
118109
assert types == {}
119110

120111

121-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
122112
def test_keyword_with_annotation_external_class(lib_types):
123113
types = lib_types.get_keyword_types('keyword_with_webdriver')
124114
assert types == {'arg': CustomObject}
125115

126116

127-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
128117
def test_keyword_with_annotation_and_default(lib_types):
129118
types = lib_types.get_keyword_types('keyword_default_and_annotation')
130119
assert types == {'arg1': int, 'arg2': Union[bool, str]}
131120

132121

133-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
134122
def test_keyword_with_robot_types_and_annotations(lib_types):
135123
types = lib_types.get_keyword_types('keyword_robot_types_and_annotations')
136124
assert types == {'arg': str}
137125

138126

139-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
140127
def test_keyword_with_robot_types_disbaled_and_annotations(lib_types):
141128
types = lib_types.get_keyword_types('keyword_robot_types_disabled_and_annotations')
142129
assert types is None
143130

144131

145-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
146132
def test_keyword_with_robot_types_and_bool_annotations(lib_types):
147133
types = lib_types.get_keyword_types('keyword_robot_types_and_bool_hint')
148134
assert types == {'arg1': str}
149135

150-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
151136
def test_init_args(lib_types):
152137
types = lib_types.get_keyword_types('__init__')
153138
assert types == {'arg': str}
@@ -163,85 +148,72 @@ def test_varargs(lib):
163148
assert types == {}
164149

165150

166-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
167151
def test_init_args_with_annotation(lib_types):
168152
types = lib_types.get_keyword_types('__init__')
169153
assert types == {'arg': str}
170154

171155

172-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
173156
def test_exception_in_annotations(lib_types):
174157
types = lib_types.get_keyword_types('keyword_exception_annotations')
175158
assert types == {'arg': 'NotHere'}
176159

177160

178-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
179161
def test_keyword_only_arguments(lib_types):
180162
types = lib_types.get_keyword_types('keyword_only_arguments')
181163
assert types == {}
182164

183165

184166
@pytest.mark.skipif(RF31, reason='Only for RF3.2+')
185-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
186167
def test_keyword_only_arguments_many(lib_types):
187168
types = lib_types.get_keyword_types('keyword_only_arguments_many')
188169
assert types == {}
189170

190171

191172
@pytest.mark.skipif(not RF31, reason='Only for RF3.1')
192-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
193173
def test_keyword_only_arguments_many(lib_types):
194174
types = lib_types.get_keyword_types('keyword_only_arguments_many')
195175
assert types == {}
196176

197177

198-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
199178
def test_keyword_mandatory_and_keyword_only_arguments(lib_types):
200179
types = lib_types.get_keyword_types('keyword_mandatory_and_keyword_only_arguments')
201180
assert types == {'arg': int, 'some': bool}
202181

203182

204183
@pytest.mark.skipif(RF31, reason='Only for RF3.2+')
205-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
206184
def test_keyword_only_arguments_many_positional_and_default_rf32(lib_types):
207185
types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default')
208186
assert types == {'four': Union[int, str], 'six': Union[bool, str]}
209187

210188

211189
@pytest.mark.skipif(not RF31, reason='Only for RF3.1')
212-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
213190
def test_keyword_only_arguments_many_positional_and_default_rf31(lib_types):
214191
types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default')
215192
assert types == {'four': Union[int, str], 'six': Union[bool, str]}
216193

217194

218195
@pytest.mark.skipif(RF31, reason='Only for RF3.2+')
219-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
220196
def test_keyword_all_args_rf32(lib_types):
221197
types = lib_types.get_keyword_types('keyword_all_args')
222198
assert types == {}
223199

224200

225201
@pytest.mark.skipif(not RF31, reason='Only for RF3.1')
226-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
227202
def test_keyword_all_args_rf31(lib_types):
228203
types = lib_types.get_keyword_types('keyword_all_args')
229204
assert types == {}
230205

231206

232-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
233207
def test_keyword_self_and_types(lib_types):
234208
types = lib_types.get_keyword_types('keyword_self_and_types')
235209
assert types == {'mandatory': str, 'other': bool}
236210

237211

238-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
239212
def test_keyword_self_and_keyword_only_types(lib_types):
240213
types = lib_types.get_keyword_types('keyword_self_and_keyword_only_types')
241214
assert types == {'varargs': int, 'other': bool, 'kwargs': int}
242215

243216

244-
@pytest.mark.skipif(PY2, reason='Only applicable on Python 3')
245217
def test_keyword_with_decorator_arguments(lib_types):
246218
types = lib_types.get_keyword_types('keyword_with_deco_and_signature')
247219
assert types == {'arg1': bool, 'arg2': bool}

utest/test_keyword_builder.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pytest
22

3-
from robotlibcore import PY2, RF31, KeywordBuilder
3+
from robotlibcore import RF31, KeywordBuilder
44
from moc_library import MockLibrary
5-
if not PY2:
6-
from moc_library_py3 import MockLibraryPy3
7-
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
5+
from moc_library_py3 import MockLibraryPy3
6+
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
87

98

109
@pytest.fixture
@@ -68,20 +67,17 @@ def test_varargs_and_kwargs(lib):
6867
assert spec.argument_specification == ['*vargs', '**kwargs']
6968

7069

71-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
7270
def test_named_only(lib_py3):
7371
spec = KeywordBuilder.build(lib_py3.named_only)
7472
assert spec.argument_specification == ['*varargs', 'key1', 'key2']
7573

7674

77-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
7875
@pytest.mark.skipif(RF31, reason='Only for RF3.2+')
7976
def test_named_only_rf32(lib_py3):
8077
spec = KeywordBuilder.build(lib_py3.named_only_with_defaults)
8178
assert spec.argument_specification == ['*varargs', 'key1', 'key2', ('key3', 'default1'), ('key4', True)]
8279

8380

84-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
8581
@pytest.mark.skipif(not RF31, reason='Only for RF3.1')
8682
def test_named_only_rf31(lib_py3):
8783
spec = KeywordBuilder.build(lib_py3.named_only_with_defaults)
@@ -98,25 +94,21 @@ def test_types_disabled_in_keyword_deco(lib):
9894
assert spec.argument_types is None
9995

10096

101-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
10297
def test_types_(lib_py3):
10398
spec = KeywordBuilder.build(lib_py3.args_with_type_hints)
10499
assert spec.argument_types == {'arg3': str, 'arg4': type(None)}
105100

106101

107-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
108102
def test_types(lib_py3):
109103
spec = KeywordBuilder.build(lib_py3.self_and_keyword_only_types)
110104
assert spec.argument_types == {'varargs': int, 'other': bool, 'kwargs': int}
111105

112106

113-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
114107
def test_optional_none(lib_py3):
115108
spec = KeywordBuilder.build(lib_py3.optional_none)
116109
assert spec.argument_types == {'arg1': str, 'arg2': str}
117110

118111

119-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
120112
@pytest.mark.skipif(RF31, reason='For RF 3.2')
121113
def test_complex_deco_rf32(dyn_types):
122114
spec = KeywordBuilder.build(dyn_types.keyword_with_deco_and_signature)
@@ -125,7 +117,6 @@ def test_complex_deco_rf32(dyn_types):
125117
assert spec.documentation == "Test me doc here"
126118

127119

128-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
129120
@pytest.mark.skipif(not RF31, reason='For RF 3.2')
130121
def test_complex_deco_rf31(dyn_types):
131122
spec = KeywordBuilder.build(dyn_types.keyword_with_deco_and_signature)

utest/test_robotlibcore.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import sys
2-
31
import pytest
42
from robot import __version__ as robot_version
53

6-
from robotlibcore import HybridCore, PY2
4+
from robotlibcore import HybridCore
75
from HybridLibrary import HybridLibrary
86
from DynamicLibrary import DynamicLibrary
9-
if not PY2:
10-
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
7+
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
118

129

1310
@pytest.fixture(scope='module')
@@ -125,7 +122,6 @@ def test_get_keyword_arguments_rf32():
125122
args('__foobar__')
126123

127124

128-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
129125
@pytest.mark.skipif(robot_version < '3.2', reason='For RF 3.2 or greater')
130126
def test_keyword_only_arguments_for_get_keyword_arguments_rf32():
131127
args = DynamicTypesAnnotationsLibrary(1).get_keyword_arguments
@@ -138,7 +134,6 @@ def test_keyword_only_arguments_for_get_keyword_arguments_rf32():
138134
assert args('keyword_with_deco_and_signature') == [('arg1', False), ('arg2', False)]
139135

140136

141-
@pytest.mark.skipif(PY2, reason='Only for Python 3')
142137
@pytest.mark.skipif(robot_version >= '3.2', reason='For RF 3.1')
143138
def test_keyword_only_arguments_for_get_keyword_arguments_rf31():
144139
args = DynamicTypesAnnotationsLibrary(1).get_keyword_arguments
@@ -176,13 +171,3 @@ def test_library_cannot_be_class():
176171
HybridCore([HybridLibrary])
177172
assert str(exc_info.value) == \
178173
"Libraries must be modules or instances, got class 'HybridLibrary' instead."
179-
180-
181-
@pytest.mark.skipif(sys.version_info[0] > 2, reason='Only applicable on Py 2')
182-
def test_library_cannot_be_old_style_class_instance():
183-
class OldStyle:
184-
pass
185-
with pytest.raises(TypeError) as exc_info:
186-
HybridCore([OldStyle()])
187-
assert str(exc_info.value) == \
188-
"Libraries must be modules or new-style class instances, got old-style class 'OldStyle' instead."

0 commit comments

Comments
 (0)