forked from robotframework/PythonRemoteServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_argsdocs.py
More file actions
executable file
·85 lines (56 loc) · 2.4 KB
/
Copy pathtest_argsdocs.py
File metadata and controls
executable file
·85 lines (56 loc) · 2.4 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Module doc - used in tests"""
import unittest
from robotremoteserver import RemoteLibraryFactory
class LibraryWithArgsAndDocs:
"""Intro doc"""
def __init__(self, i1, i2=1, *i3):
"""Init doc"""
def keyword(self, k1, k2=2, *k3):
"""Keyword doc"""
def no_doc_or_args(self):
pass
def keyword_in_module(m1, m2=3, *m3):
"""Module keyword doc"""
class TestDocs(unittest.TestCase):
def test_keyword_doc(self):
self._test_doc('keyword', 'Keyword doc')
def test_keyword_doc_when_no_doc(self):
self._test_doc('no_doc_or_args', '')
def test_intro_doc(self):
self._test_doc('__intro__', 'Intro doc')
def test_init_doc(self):
self._test_doc('__init__', 'Init doc')
def test_init_doc_when_old_style_lib_has_no_init(self):
class OldStyleLibraryWithoutInit:
pass
self._test_doc('__init__', '', OldStyleLibraryWithoutInit())
def test_init_doc_when_new_style_lib_has_no_init(self):
class NewStyleLibraryWithoutInit(object):
pass
self._test_doc('__init__', '', NewStyleLibraryWithoutInit())
def test_keyword_doc_from_module_keyword(self):
import test_argsdocs
self._test_doc('keyword_in_module', 'Module keyword doc', test_argsdocs)
def test_init_doc_from_module(self):
import test_argsdocs
self._test_doc('__init__', '', test_argsdocs)
def test_intro_doc_from_module(self):
import test_argsdocs
self._test_doc('__intro__', 'Module doc - used in tests', test_argsdocs)
def _test_doc(self, name, expected, library=LibraryWithArgsAndDocs(None)):
library = RemoteLibraryFactory(library)
self.assertEquals(library.get_keyword_documentation(name), expected)
class TestArgs(unittest.TestCase):
def test_keyword_args(self):
self._test_args('keyword', ['k1', 'k2=2', '*k3'])
def test_keyword_args_when_no_args(self):
self._test_args('no_doc_or_args', [])
def test_keyword_args_from_module_keyword(self):
import test_argsdocs
self._test_args('keyword_in_module', ['m1', 'm2=3', '*m3'],
test_argsdocs)
def _test_args(self, name, expected, library=LibraryWithArgsAndDocs(None)):
library = RemoteLibraryFactory(library)
self.assertEquals(library.get_keyword_arguments(name), expected)
if __name__ == '__main__':
unittest.main()