Skip to content

Commit 510da00

Browse files
hugovkaaltat
authored andcommitted
Refactor moc_library_py3 into moc_library
1 parent 873b381 commit 510da00

File tree

3 files changed

+29
-37
lines changed

3 files changed

+29
-37
lines changed

atest/moc_library.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from robot.api.deco import keyword
24

35

@@ -27,3 +29,18 @@ def default_only(self, named1='string1', named2=123):
2729

2830
def varargs_kwargs(self, *vargs, **kwargs):
2931
pass
32+
33+
def named_only(self, *varargs, key1, key2):
34+
pass
35+
36+
def named_only_with_defaults(self, *varargs, key1, key2, key3='default1', key4=True):
37+
pass
38+
39+
def args_with_type_hints(self, arg1, arg2, arg3: str, arg4: None) -> bool:
40+
pass
41+
42+
def self_and_keyword_only_types(x: 'MockLibrary', mandatory, *varargs: int, other: bool, **kwargs: int):
43+
pass
44+
45+
def optional_none(self, xxx, arg1: Optional[str] = None, arg2: Optional[str] = None, arg3=False):
46+
pass

atest/moc_library_py3.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

utest/test_keyword_builder.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from robotlibcore import RF31, KeywordBuilder
44
from moc_library import MockLibrary
5-
from moc_library_py3 import MockLibraryPy3
65
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
76

87

@@ -11,11 +10,6 @@ def lib():
1110
return MockLibrary()
1211

1312

14-
@pytest.fixture
15-
def lib_py3():
16-
return MockLibraryPy3()
17-
18-
1913
@pytest.fixture
2014
def dyn_types():
2115
return DynamicTypesAnnotationsLibrary(1)
@@ -67,20 +61,20 @@ def test_varargs_and_kwargs(lib):
6761
assert spec.argument_specification == ['*vargs', '**kwargs']
6862

6963

70-
def test_named_only(lib_py3):
71-
spec = KeywordBuilder.build(lib_py3.named_only)
64+
def test_named_only(lib):
65+
spec = KeywordBuilder.build(lib.named_only)
7266
assert spec.argument_specification == ['*varargs', 'key1', 'key2']
7367

7468

7569
@pytest.mark.skipif(RF31, reason='Only for RF3.2+')
76-
def test_named_only_rf32(lib_py3):
77-
spec = KeywordBuilder.build(lib_py3.named_only_with_defaults)
70+
def test_named_only_rf32(lib):
71+
spec = KeywordBuilder.build(lib.named_only_with_defaults)
7872
assert spec.argument_specification == ['*varargs', 'key1', 'key2', ('key3', 'default1'), ('key4', True)]
7973

8074

8175
@pytest.mark.skipif(not RF31, reason='Only for RF3.1')
82-
def test_named_only_rf31(lib_py3):
83-
spec = KeywordBuilder.build(lib_py3.named_only_with_defaults)
76+
def test_named_only_rf31(lib):
77+
spec = KeywordBuilder.build(lib.named_only_with_defaults)
8478
assert spec.argument_specification == ['*varargs', 'key1', 'key2', 'key3=default1', 'key4=True']
8579

8680

@@ -94,18 +88,18 @@ def test_types_disabled_in_keyword_deco(lib):
9488
assert spec.argument_types is None
9589

9690

97-
def test_types_(lib_py3):
98-
spec = KeywordBuilder.build(lib_py3.args_with_type_hints)
91+
def test_types_(lib):
92+
spec = KeywordBuilder.build(lib.args_with_type_hints)
9993
assert spec.argument_types == {'arg3': str, 'arg4': type(None)}
10094

10195

102-
def test_types(lib_py3):
103-
spec = KeywordBuilder.build(lib_py3.self_and_keyword_only_types)
96+
def test_types(lib):
97+
spec = KeywordBuilder.build(lib.self_and_keyword_only_types)
10498
assert spec.argument_types == {'varargs': int, 'other': bool, 'kwargs': int}
10599

106100

107-
def test_optional_none(lib_py3):
108-
spec = KeywordBuilder.build(lib_py3.optional_none)
101+
def test_optional_none(lib):
102+
spec = KeywordBuilder.build(lib.optional_none)
109103
assert spec.argument_types == {'arg1': str, 'arg2': str}
110104

111105

0 commit comments

Comments
 (0)