Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/CallTips.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | eea379307efa |
| children | 181c170c6270 |
| rev | line source |
|---|---|
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
1 """CallTips.py - An IDLE Extension to Jog Your Memory |
| 13975 | 2 |
| 26623 | 3 Call Tips are floating windows which display function, class, and method |
| 4 parameter and docstring information when you type an opening parenthesis, and | |
| 5 which disappear when you type a closing parenthesis. | |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40775
diff
changeset
|
6 |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
7 """ |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40775
diff
changeset
|
8 import re |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
9 import sys |
| 13975 | 10 import types |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
11 import inspect |
| 13975 | 12 |
|
42714
2ec16b6b4d04
Switch to absolute imports to support direct execution of modules. Many
Kurt B. Kaiser <kbk@shore.net>
parents:
42338
diff
changeset
|
13 from idlelib import CallTipWindow |
|
2ec16b6b4d04
Switch to absolute imports to support direct execution of modules. Many
Kurt B. Kaiser <kbk@shore.net>
parents:
42338
diff
changeset
|
14 from idlelib.HyperParser import HyperParser |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
15 |
|
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
16 import __main__ |
|
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
17 |
| 13975 | 18 class CallTips: |
| 19 | |
| 20 menudefs = [ | |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
21 ('edit', [ |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
22 ("Show call tip", "<<force-open-calltip>>"), |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
23 ]) |
| 13975 | 24 ] |
| 25 | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
26 def __init__(self, editwin=None): |
|
31966
204b7bcead4c
Testing for None should be done with 'is'
Raymond Hettinger <python@rcn.com>
parents:
29983
diff
changeset
|
27 if editwin is None: # subprocess and test |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
28 self.editwin = None |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
29 else: |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
30 self.editwin = editwin |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
31 self.text = editwin.text |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
32 self.active_calltip = None |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
33 self._calltip_window = self._make_tk_calltip_window |
| 13975 | 34 |
| 35 def close(self): | |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
36 self._calltip_window = None |
| 13975 | 37 |
| 38 def _make_tk_calltip_window(self): | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
39 # See __init__ for usage |
| 13975 | 40 return CallTipWindow.CallTip(self.text) |
| 41 | |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
42 def _remove_calltip_window(self, event=None): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
43 if self.active_calltip: |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
44 self.active_calltip.hidetip() |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
45 self.active_calltip = None |
|
18527
e4d6a739997d
py-cvs-rel2_1 (Rev 1.8) merge - whitespace normalization
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
46 |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
47 def force_open_calltip_event(self, event): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
48 "The user selected the menu entry or hotkey, open the tip." |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
49 self.open_calltip(True) |
| 13975 | 50 |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
51 def try_open_calltip_event(self, event): |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
52 """Happens when it would be nice to open a CallTip, but not really |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
53 necessary, for example after an opening bracket, so function calls |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
54 won't be made. |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
55 """ |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
56 self.open_calltip(False) |
| 13975 | 57 |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
58 def refresh_calltip_event(self, event): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
59 if self.active_calltip and self.active_calltip.is_active(): |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
60 self.open_calltip(False) |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
61 |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
62 def open_calltip(self, evalfuncs): |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
63 self._remove_calltip_window() |
| 13975 | 64 |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
65 hp = HyperParser(self.editwin, "insert") |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
66 sur_paren = hp.get_surrounding_brackets('(') |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
67 if not sur_paren: |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
68 return |
|
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
69 hp.set_index(sur_paren[0]) |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
70 expression = hp.get_expression() |
|
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
71 if not expression: |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
72 return |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
73 if not evalfuncs and (expression.find('(') != -1): |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
74 return |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
75 argspec = self.fetch_tip(expression) |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
76 if not argspec: |
|
35891
8fd46b660e66
Merge IDLE-syntax-branch r39668:41449 into trunk
Kurt B. Kaiser <kbk@shore.net>
parents:
31966
diff
changeset
|
77 return |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
78 self.active_calltip = self._calltip_window() |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
79 self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1]) |
| 26959 | 80 |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
81 def fetch_tip(self, expression): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
82 """Return the argument list and docstring of a function or class. |
| 26959 | 83 |
| 26623 | 84 If there is a Python subprocess, get the calltip there. Otherwise, |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
85 either this fetch_tip() is running in the subprocess or it was |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
86 called in an IDLE running without the subprocess. |
| 26623 | 87 |
| 88 The subprocess environment is that of the most recently run script. If | |
| 89 two unrelated modules are being edited some calltips in the current | |
| 90 module may be inoperative if the module was not the last to run. | |
| 91 | |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40775
diff
changeset
|
92 To find methods, fetch_tip must be fed a fully qualified name. |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40775
diff
changeset
|
93 |
| 26959 | 94 """ |
| 26623 | 95 try: |
| 96 rpcclt = self.editwin.flist.pyshell.interp.rpcclt | |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
97 except AttributeError: |
| 26623 | 98 rpcclt = None |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
99 if rpcclt: |
|
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
100 return rpcclt.remotecall("exec", "get_the_calltip", |
|
77316
f927a5c6e4be
Issue 12510: Expand 2 bare excepts. Improve comments. Change deceptive name
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77195
diff
changeset
|
101 (expression,), {}) |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
102 else: |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
103 return get_argspec(get_entity(expression)) |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25282
diff
changeset
|
104 |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
105 def get_entity(expression): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
106 """Return the object corresponding to expression evaluated |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
107 in a namespace spanning sys.modules and __main.dict__. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
108 """ |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
109 if expression: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
110 namespace = sys.modules.copy() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
111 namespace.update(__main__.__dict__) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
112 try: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
113 return eval(expression, namespace) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
114 except BaseException: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
115 # An uncaught exception closes idle, and eval can raise any |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
116 # exception, especially if user classes are involved. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
117 return None |
| 13975 | 118 |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
119 # The following are used in both get_argspec and tests |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
120 _first_param = re.compile('(?<=\()\w*\,?\s*') |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
121 _default_callable_argspec = "No docstring, see docs." |
| 13975 | 122 |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
123 def get_argspec(ob): |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
124 '''Return a string describing the arguments and return of a callable object. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
125 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
126 For Python-coded functions and methods, the first line is introspected. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
127 Delete 'self' parameter for classes (.__init__) and bound methods. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
128 The last line is the first line of the doc string. For builtins, this typically |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
129 includes the arguments in addition to the return value. |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
130 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
131 ''' |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
132 argspec = "" |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
133 if hasattr(ob, '__call__'): |
|
41986
6464cc638faa
Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41717
diff
changeset
|
134 if isinstance(ob, type): |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
135 fob = getattr(ob, '__init__', None) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
136 elif isinstance(ob.__call__, types.MethodType): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
137 fob = ob.__call__ |
| 13975 | 138 else: |
| 139 fob = ob | |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
140 if isinstance(fob, (types.FunctionType, types.MethodType)): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
141 argspec = inspect.formatargspec(*inspect.getfullargspec(fob)) |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
142 if (isinstance(ob, (type, types.MethodType)) or |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
143 isinstance(ob.__call__, types.MethodType)): |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
144 argspec = _first_param.sub("", argspec) |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
145 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
146 if isinstance(ob.__call__, types.MethodType): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
147 doc = ob.__call__.__doc__ |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
148 else: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
149 doc = getattr(ob, "__doc__", "") |
| 25282 | 150 if doc: |
|
29983
1bd6e62fb06f
1. Python Bug 775541: Calltips error when docstring is None. Introduced
Kurt B. Kaiser <kbk@shore.net>
parents:
29841
diff
changeset
|
151 doc = doc.lstrip() |
| 25282 | 152 pos = doc.find("\n") |
| 153 if pos < 0 or pos > 70: | |
| 154 pos = 70 | |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
155 if argspec: |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
156 argspec += "\n" |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
157 argspec += doc[:pos] |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
158 if not argspec: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
159 argspec = _default_callable_argspec |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
160 return argspec |
| 13975 | 161 |
| 162 ################################################# | |
| 163 # | |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
164 # Test code tests CallTips.fetch_tip, get_entity, and get_argspec |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
165 |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
166 def main(): |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
167 # Putting expected in docstrings results in doubled tips for test |
| 13975 | 168 def t1(): "()" |
| 169 def t2(a, b=None): "(a, b=None)" | |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
170 def t3(a, *args): "(a, *args)" |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
171 def t4(*args): "(*args)" |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
172 def t5(a, b=None, *args, **kw): "(a, b=None, *args, **kw)" |
| 13975 | 173 |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40775
diff
changeset
|
174 class TC(object): |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
175 "(ai=None, *b)" |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
176 def __init__(self, ai=None, *b): "(self, ai=None, *b)" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
177 def t1(self): "(self)" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
178 def t2(self, ai, b=None): "(self, ai, b=None)" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
179 def t3(self, ai, *args): "(self, ai, *args)" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
180 def t4(self, *args): "(self, *args)" |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
181 def t5(self, ai, b=None, *args, **kw): "(self, ai, b=None, *args, **kw)" |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
182 def t6(no, self): "(no, self)" |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
183 @classmethod |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
184 def cm(cls, a): "(cls, a)" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
185 @staticmethod |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
186 def sm(b): "(b)" |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
187 def __call__(self, ci): "(self, ci)" |
| 13975 | 188 |
| 189 tc = TC() | |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
190 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
191 # Python classes that inherit builtin methods |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
192 class Int(int): "Int(x[, base]) -> integer" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
193 class List(list): "List() -> new empty list" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
194 # Simulate builtin with no docstring for default argspec test |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
195 class SB: __call__ = None |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
196 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
197 __main__.__dict__.update(locals()) # required for get_entity eval() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
198 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
199 num_tests = num_fail = 0 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
200 tip = CallTips().fetch_tip |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
201 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
202 def test(expression, expected): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
203 nonlocal num_tests, num_fail |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
204 num_tests += 1 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
205 argspec = tip(expression) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
206 if argspec != expected: |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
207 num_fail += 1 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
208 fmt = "%s - expected\n%r\n - but got\n%r" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
209 print(fmt % (expression, expected, argspec)) |
| 13975 | 210 |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
211 def test_builtins(): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
212 # if first line of a possibly multiline compiled docstring changes, |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
213 # must change corresponding test string |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
214 test('int', "int(x[, base]) -> integer") |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
215 test('Int', Int.__doc__) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
216 test('types.MethodType', "method(function, instance)") |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
217 test('list', "list() -> new empty list") |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
218 test('List', List.__doc__) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
219 test('list.__new__', |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
220 'T.__new__(S, ...) -> a new object with type S, a subtype of T') |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
221 test('list.__init__', |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
222 'x.__init__(...) initializes x; see help(type(x)) for signature') |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
223 append_doc = "L.append(object) -> None -- append object to end" |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
224 test('list.append', append_doc) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
225 test('[].append', append_doc) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
226 test('List.append', append_doc) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
227 test('SB()', _default_callable_argspec) |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
228 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
229 def test_funcs(): |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
230 for func in (t1, t2, t3, t4, t5, TC,): |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
231 fdoc = func.__doc__ |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
232 test(func.__name__, fdoc + "\n" + fdoc) |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
233 for func in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.sm, |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
234 TC.__call__): |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
235 fdoc = func.__doc__ |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
236 test('TC.'+func.__name__, fdoc + "\n" + fdoc) |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
237 fdoc = TC.cm.__func__.__doc__ |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
238 test('TC.cm.__func__', fdoc + "\n" + fdoc) |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
239 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
240 def test_methods(): |
|
78019
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
241 # test that first parameter is correctly removed from argspec |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
242 # using _first_param re to calculate expected masks re errors |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
243 for meth, mdoc in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"), |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
244 (TC.cm, "(a)"),): |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
245 test('tc.'+meth.__name__, mdoc + "\n" + meth.__doc__) |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
246 test('tc', "(ci)" + "\n" + tc.__call__.__doc__) |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
247 # directly test that re works to delete unicode parameter name |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
248 uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)" # various As |
|
eea379307efa
Issue 12510: Delete actual first param name for all methods; revise tests.
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77380
diff
changeset
|
249 assert _first_param.sub('', uni) == '(a)' |
|
77380
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
250 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
251 def test_non_callables(): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
252 # expression evaluates, but not to a callable |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
253 for expr in ('0', '0.0' 'num_tests', b'num_tests', '[]', '{}'): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
254 test(expr, '') |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
255 # expression does not evaluate, but raises an exception |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
256 for expr in ('1a', 'xyx', 'num_tests.xyz', '[int][1]', '{0:int}[1]'): |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
257 test(expr, '') |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
258 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
259 test_builtins() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
260 test_funcs() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
261 test_non_callables() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
262 test_methods() |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
263 |
|
02b4c62ce393
Issue #12510: Revise and triple # of calltip tests, with an eye to unittest
Terry Jan Reedy <tjreedy@udel.edu>
parents:
77316
diff
changeset
|
264 print("%d of %d tests failed" % (num_fail, num_tests)) |
|
43037
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
265 |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
266 if __name__ == '__main__': |
|
cc7e914a22d9
Use inspect.py and clean up.
Kurt B. Kaiser <kbk@shore.net>
parents:
42853
diff
changeset
|
267 main() |
