| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  | "Test calltip, coverage 60%" | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  | from idlelib import calltip | 
					
						
							| 
									
										
										
										
											2013-05-27 21:32:03 -04:00
										 |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  | import textwrap | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | import types | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  | import re | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Test Class TC is used in multiple get_argspec test methods | 
					
						
							|  |  |  | class TC(): | 
					
						
							|  |  |  |     'doc' | 
					
						
							|  |  |  |     tip = "(ai=None, *b)" | 
					
						
							|  |  |  |     def __init__(self, ai=None, *b): 'doc' | 
					
						
							|  |  |  |     __init__.tip = "(self, ai=None, *b)" | 
					
						
							|  |  |  |     def t1(self): 'doc' | 
					
						
							|  |  |  |     t1.tip = "(self)" | 
					
						
							|  |  |  |     def t2(self, ai, b=None): 'doc' | 
					
						
							|  |  |  |     t2.tip = "(self, ai, b=None)" | 
					
						
							|  |  |  |     def t3(self, ai, *args): 'doc' | 
					
						
							|  |  |  |     t3.tip = "(self, ai, *args)" | 
					
						
							|  |  |  |     def t4(self, *args): 'doc' | 
					
						
							|  |  |  |     t4.tip = "(self, *args)" | 
					
						
							|  |  |  |     def t5(self, ai, b=None, *args, **kw): 'doc' | 
					
						
							|  |  |  |     t5.tip = "(self, ai, b=None, *args, **kw)" | 
					
						
							|  |  |  |     def t6(no, self): 'doc' | 
					
						
							|  |  |  |     t6.tip = "(no, self)" | 
					
						
							|  |  |  |     def __call__(self, ci): 'doc' | 
					
						
							|  |  |  |     __call__.tip = "(self, ci)" | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |     def nd(self): pass  # No doc. | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |     # attaching .tip to wrapped methods does not work | 
					
						
							|  |  |  |     @classmethod | 
					
						
							|  |  |  |     def cm(cls, a): 'doc' | 
					
						
							|  |  |  |     @staticmethod | 
					
						
							|  |  |  |     def sm(b): 'doc' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | tc = TC() | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  | default_tip = calltip._default_callable_argspec | 
					
						
							|  |  |  | get_spec = calltip.get_argspec | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  | class Get_argspecTest(unittest.TestCase): | 
					
						
							|  |  |  |     # The get_spec function must return a string, even if blank. | 
					
						
							| 
									
										
										
										
											2014-01-21 03:07:51 -05:00
										 |  |  |     # Test a variety of objects to be sure that none cause it to raise | 
					
						
							|  |  |  |     # (quite aside from getting as correct an answer as possible). | 
					
						
							|  |  |  |     # The tests of builtins may break if inspect or the docstrings change, | 
					
						
							|  |  |  |     # but a red buildbot is better than a user crash (as has happened). | 
					
						
							|  |  |  |     # For a simple mismatch, change the expected output to the actual. | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_builtins(self): | 
					
						
							| 
									
										
										
										
											2014-01-21 03:07:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         def tiptest(obj, out): | 
					
						
							|  |  |  |             self.assertEqual(get_spec(obj), out) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |         # Python class that inherits builtin methods | 
					
						
							|  |  |  |         class List(list): "List() doc" | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 20:45:17 -05:00
										 |  |  |         # Simulate builtin with no docstring for default tip test | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |         class SB:  __call__ = None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-04 09:47:31 +03:00
										 |  |  |         if List.__doc__ is not None: | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             tiptest(List, | 
					
						
							|  |  |  |                     f'(iterable=(), /){calltip._argument_positional}' | 
					
						
							|  |  |  |                     f'\n{List.__doc__}') | 
					
						
							|  |  |  |         tiptest(list.__new__, | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |               '(*args, **kwargs)\n' | 
					
						
							|  |  |  |               'Create and return a new object.  ' | 
					
						
							|  |  |  |               'See help(type) for accurate signature.') | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         tiptest(list.__init__, | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |               '(self, /, *args, **kwargs)' | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |               + calltip._argument_positional + '\n' + | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |               'Initialize self.  See help(type(self)) for accurate signature.') | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |         append_doc = (calltip._argument_positional | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |                       + "\nAppend object to the end of the list.") | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         tiptest(list.append, '(self, object, /)' + append_doc) | 
					
						
							|  |  |  |         tiptest(List.append, '(self, object, /)' + append_doc) | 
					
						
							|  |  |  |         tiptest([].append, '(object, /)' + append_doc) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         tiptest(types.MethodType, "method(function, instance)") | 
					
						
							|  |  |  |         tiptest(SB(), default_tip) | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  |         p = re.compile('') | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         tiptest(re.sub, '''\
 | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | (pattern, repl, string, count=0, flags=0) | 
					
						
							|  |  |  | Return the string obtained by replacing the leftmost | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  | non-overlapping occurrences of the pattern in string by the | 
					
						
							|  |  |  | replacement repl.  repl can be either a string or a callable; | 
					
						
							|  |  |  | if a string, backslash escapes in it are processed.  If it is | 
					
						
							| 
									
										
										
										
											2017-10-04 20:09:49 +03:00
										 |  |  | a callable, it's passed the Match object and must return''') | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         tiptest(p.sub, '''\
 | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | (repl, string, count=0) | 
					
						
							|  |  |  | Return the string obtained by replacing the leftmost \ | 
					
						
							|  |  |  | non-overlapping occurrences o...''')
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  |     def test_signature_wrap(self): | 
					
						
							| 
									
										
										
										
											2015-04-04 09:47:31 +03:00
										 |  |  |         if textwrap.TextWrapper.__doc__ is not None: | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             self.assertEqual(get_spec(textwrap.TextWrapper), '''\
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  | (width=70, initial_indent='', subsequent_indent='', expand_tabs=True, | 
					
						
							|  |  |  |     replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, | 
					
						
							| 
									
										
										
										
											2014-01-26 20:08:26 -05:00
										 |  |  |     drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, | 
					
						
							|  |  |  |     placeholder=' [...]')''')
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 04:47:58 -03:00
										 |  |  |     def test_properly_formated(self): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 04:47:58 -03:00
										 |  |  |         def foo(s='a'*100): | 
					
						
							|  |  |  |             pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def bar(s='a'*100): | 
					
						
							|  |  |  |             """Hello Guido""" | 
					
						
							|  |  |  |             pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def baz(s='a'*100, z='b'*100): | 
					
						
							|  |  |  |             pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         indent = calltip._INDENT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         sfoo = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaa')" | 
					
						
							|  |  |  |         sbar = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaa')\nHello Guido" | 
					
						
							|  |  |  |         sbaz = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | 
					
						
							|  |  |  |                "aaaaaaaaaa', z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"\ | 
					
						
							|  |  |  |                "bbbbbbbbbbbbbbbbb\n" + indent + "bbbbbbbbbbbbbbbbbbbbbb"\ | 
					
						
							|  |  |  |                "bbbbbbbbbbbbbbbbbbbbbb')" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for func,doc in [(foo, sfoo), (bar, sbar), (baz, sbaz)]: | 
					
						
							|  |  |  |             with self.subTest(func=func, doc=doc): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(func), doc) | 
					
						
							| 
									
										
										
										
											2019-01-03 04:47:58 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  |     def test_docline_truncation(self): | 
					
						
							|  |  |  |         def f(): pass | 
					
						
							|  |  |  |         f.__doc__ = 'a'*300 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         self.assertEqual(get_spec(f), f"()\n{'a'*(calltip._MAX_COLS-3) + '...'}") | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 20:45:17 -05:00
										 |  |  |     def test_multiline_docstring(self): | 
					
						
							|  |  |  |         # Test fewer lines than max. | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         self.assertEqual(get_spec(range), | 
					
						
							| 
									
										
										
										
											2017-03-11 09:19:20 +02:00
										 |  |  |                 "range(stop) -> range object\n" | 
					
						
							|  |  |  |                 "range(start, stop[, step]) -> range object") | 
					
						
							| 
									
										
										
										
											2014-01-21 20:45:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  |         # Test max lines | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         self.assertEqual(get_spec(bytes), '''\
 | 
					
						
							| 
									
										
										
										
											2014-01-26 19:55:34 -05:00
										 |  |  | bytes(iterable_of_ints) -> bytes | 
					
						
							|  |  |  | bytes(string, encoding[, errors]) -> bytes | 
					
						
							|  |  |  | bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer | 
					
						
							|  |  |  | bytes(int) -> bytes object of size given by the parameter initialized with null bytes | 
					
						
							|  |  |  | bytes() -> empty bytes object''')
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Test more than max lines | 
					
						
							|  |  |  |         def f(): pass | 
					
						
							|  |  |  |         f.__doc__ = 'a\n' * 15 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         self.assertEqual(get_spec(f), '()' + '\na' * calltip._MAX_LINES) | 
					
						
							| 
									
										
										
										
											2014-01-21 20:45:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |     def test_functions(self): | 
					
						
							|  |  |  |         def t1(): 'doc' | 
					
						
							|  |  |  |         t1.tip = "()" | 
					
						
							|  |  |  |         def t2(a, b=None): 'doc' | 
					
						
							|  |  |  |         t2.tip = "(a, b=None)" | 
					
						
							|  |  |  |         def t3(a, *args): 'doc' | 
					
						
							|  |  |  |         t3.tip = "(a, *args)" | 
					
						
							|  |  |  |         def t4(*args): 'doc' | 
					
						
							|  |  |  |         t4.tip = "(*args)" | 
					
						
							|  |  |  |         def t5(a, b=None, *args, **kw): 'doc' | 
					
						
							|  |  |  |         t5.tip = "(a, b=None, *args, **kw)" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-04 09:47:31 +03:00
										 |  |  |         doc = '\ndoc' if t1.__doc__ is not None else '' | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |         for func in (t1, t2, t3, t4, t5, TC): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(func=func): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(func), func.tip + doc) | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_methods(self): | 
					
						
							| 
									
										
										
										
											2015-04-04 09:47:31 +03:00
										 |  |  |         doc = '\ndoc' if TC.__doc__ is not None else '' | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |         for meth in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.__call__): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(meth=meth): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(meth), meth.tip + doc) | 
					
						
							|  |  |  |         self.assertEqual(get_spec(TC.cm), "(a)" + doc) | 
					
						
							|  |  |  |         self.assertEqual(get_spec(TC.sm), "(b)" + doc) | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_bound_methods(self): | 
					
						
							|  |  |  |         # test that first parameter is correctly removed from argspec | 
					
						
							| 
									
										
										
										
											2015-04-04 09:47:31 +03:00
										 |  |  |         doc = '\ndoc' if TC.__doc__ is not None else '' | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |         for meth, mtip  in ((tc.t1, "()"), (tc.t4, "(*args)"), | 
					
						
							|  |  |  |                             (tc.t6, "(self)"), (tc.__call__, '(ci)'), | 
					
						
							|  |  |  |                             (tc, '(ci)'), (TC.cm, "(a)"),): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(meth=meth, mtip=mtip): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(meth), mtip + doc) | 
					
						
							| 
									
										
										
										
											2014-01-21 15:36:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-26 21:34:33 -05:00
										 |  |  |     def test_starred_parameter(self): | 
					
						
							|  |  |  |         # test that starred first parameter is *not* removed from argspec | 
					
						
							|  |  |  |         class C: | 
					
						
							|  |  |  |             def m1(*args): pass | 
					
						
							|  |  |  |         c = C() | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  |         for meth, mtip  in ((C.m1, '(*args)'), (c.m1, "(*args)"),): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(meth=meth, mtip=mtip): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(meth), mtip) | 
					
						
							| 
									
										
										
										
											2014-01-26 21:34:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |     def test_invalid_method_get_spec(self): | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  |         class C: | 
					
						
							|  |  |  |             def m2(**kwargs): pass | 
					
						
							|  |  |  |         class Test: | 
					
						
							|  |  |  |             def __call__(*, a): pass | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |         mtip = calltip._invalid_method | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         self.assertEqual(get_spec(C().m2), mtip) | 
					
						
							|  |  |  |         self.assertEqual(get_spec(Test()), mtip) | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 15:36:51 -05:00
										 |  |  |     def test_non_ascii_name(self): | 
					
						
							|  |  |  |         # test that re works to delete a first parameter name that | 
					
						
							|  |  |  |         # includes non-ascii chars, such as various forms of A. | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |         uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)" | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |         assert calltip._first_param.sub('', uni) == '(a)' | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_no_docstring(self): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |         for meth, mtip in ((TC.nd, "(self)"), (tc.nd, "()")): | 
					
						
							|  |  |  |             with self.subTest(meth=meth, mtip=mtip): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(meth), mtip) | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 15:36:51 -05:00
										 |  |  |     def test_attribute_exception(self): | 
					
						
							|  |  |  |         class NoCall: | 
					
						
							|  |  |  |             def __getattr__(self, name): | 
					
						
							|  |  |  |                 raise BaseException | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  |         class CallA(NoCall): | 
					
						
							|  |  |  |             def __call__(oui, a, b, c): | 
					
						
							|  |  |  |                 pass | 
					
						
							|  |  |  |         class CallB(NoCall): | 
					
						
							| 
									
										
										
										
											2014-01-21 15:36:51 -05:00
										 |  |  |             def __call__(self, ci): | 
					
						
							|  |  |  |                 pass | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         for meth, mtip  in ((NoCall, default_tip), (CallA, default_tip), | 
					
						
							|  |  |  |                             (NoCall(), ''), (CallA(), '(a, b, c)'), | 
					
						
							|  |  |  |                             (CallB(), '(ci)')): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(meth=meth, mtip=mtip): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(meth), mtip) | 
					
						
							| 
									
										
										
										
											2014-01-21 15:36:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-21 00:26:21 -05:00
										 |  |  |     def test_non_callables(self): | 
					
						
							|  |  |  |         for obj in (0, 0.0, '0', b'0', [], {}): | 
					
						
							| 
									
										
										
										
											2019-06-04 21:55:37 -04:00
										 |  |  |             with self.subTest(obj=obj): | 
					
						
							|  |  |  |                 self.assertEqual(get_spec(obj), '') | 
					
						
							| 
									
										
										
										
											2013-05-27 21:32:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-10 08:58:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-30 01:36:48 -04:00
										 |  |  | class Get_entityTest(unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2013-05-27 21:32:03 -04:00
										 |  |  |     def test_bad_entity(self): | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |         self.assertIsNone(calltip.get_entity('1/0')) | 
					
						
							| 
									
										
										
										
											2013-05-27 21:32:03 -04:00
										 |  |  |     def test_good_entity(self): | 
					
						
							| 
									
										
										
										
											2018-06-19 23:00:35 -04:00
										 |  |  |         self.assertIs(calltip.get_entity('int'), int) | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-27 21:32:03 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2018-06-15 18:20:55 -04:00
										 |  |  |     unittest.main(verbosity=2) |