Issue #23825: Fixed test_idle under -OO.
This commit is contained in:
parent
9f8a8910a4
commit
9fa84b202e
|
@ -52,6 +52,7 @@ class Get_signatureTest(unittest.TestCase):
|
||||||
def gtest(obj, out):
|
def gtest(obj, out):
|
||||||
self.assertEqual(signature(obj), out)
|
self.assertEqual(signature(obj), out)
|
||||||
|
|
||||||
|
if List.__doc__ is not None:
|
||||||
gtest(List, List.__doc__)
|
gtest(List, List.__doc__)
|
||||||
gtest(list.__new__,
|
gtest(list.__new__,
|
||||||
'Create and return a new object. See help(type) for accurate signature.')
|
'Create and return a new object. See help(type) for accurate signature.')
|
||||||
|
@ -66,6 +67,7 @@ class Get_signatureTest(unittest.TestCase):
|
||||||
gtest(SB(), default_tip)
|
gtest(SB(), default_tip)
|
||||||
|
|
||||||
def test_signature_wrap(self):
|
def test_signature_wrap(self):
|
||||||
|
if textwrap.TextWrapper.__doc__ is not None:
|
||||||
self.assertEqual(signature(textwrap.TextWrapper), '''\
|
self.assertEqual(signature(textwrap.TextWrapper), '''\
|
||||||
(width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
|
(width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
|
||||||
replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
|
replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
|
||||||
|
@ -108,20 +110,23 @@ bytes() -> empty bytes object''')
|
||||||
def t5(a, b=None, *args, **kw): 'doc'
|
def t5(a, b=None, *args, **kw): 'doc'
|
||||||
t5.tip = "(a, b=None, *args, **kw)"
|
t5.tip = "(a, b=None, *args, **kw)"
|
||||||
|
|
||||||
|
doc = '\ndoc' if t1.__doc__ is not None else ''
|
||||||
for func in (t1, t2, t3, t4, t5, TC):
|
for func in (t1, t2, t3, t4, t5, TC):
|
||||||
self.assertEqual(signature(func), func.tip + '\ndoc')
|
self.assertEqual(signature(func), func.tip + doc)
|
||||||
|
|
||||||
def test_methods(self):
|
def test_methods(self):
|
||||||
|
doc = '\ndoc' if TC.__doc__ is not None else ''
|
||||||
for meth in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.__call__):
|
for meth in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.__call__):
|
||||||
self.assertEqual(signature(meth), meth.tip + "\ndoc")
|
self.assertEqual(signature(meth), meth.tip + doc)
|
||||||
self.assertEqual(signature(TC.cm), "(a)\ndoc")
|
self.assertEqual(signature(TC.cm), "(a)" + doc)
|
||||||
self.assertEqual(signature(TC.sm), "(b)\ndoc")
|
self.assertEqual(signature(TC.sm), "(b)" + doc)
|
||||||
|
|
||||||
def test_bound_methods(self):
|
def test_bound_methods(self):
|
||||||
# test that first parameter is correctly removed from argspec
|
# test that first parameter is correctly removed from argspec
|
||||||
|
doc = '\ndoc' if TC.__doc__ is not None else ''
|
||||||
for meth, mtip in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"),
|
for meth, mtip in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"),
|
||||||
(tc.__call__, '(ci)'), (tc, '(ci)'), (TC.cm, "(a)"),):
|
(tc.__call__, '(ci)'), (tc, '(ci)'), (TC.cm, "(a)"),):
|
||||||
self.assertEqual(signature(meth), mtip + "\ndoc")
|
self.assertEqual(signature(meth), mtip + doc)
|
||||||
|
|
||||||
def test_starred_parameter(self):
|
def test_starred_parameter(self):
|
||||||
# test that starred first parameter is *not* removed from argspec
|
# test that starred first parameter is *not* removed from argspec
|
||||||
|
|
Loading…
Reference in New Issue