本文整理匯總了Python中idlelib.PyShell.idle_formatwarning方法的典型用法代碼示例。如果您正苦於以下問題:Python PyShell.idle_formatwarning方法的具體用法?Python PyShell.idle_formatwarning怎麽用?Python PyShell.idle_formatwarning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類idlelib.PyShell
的用法示例。
在下文中一共展示了PyShell.idle_formatwarning方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: idle_showwarning_subproc
# 需要導入模塊: from idlelib import PyShell [as 別名]
# 或者: from idlelib.PyShell import idle_formatwarning [as 別名]
def idle_showwarning_subproc(message, category, filename, lineno, file=None, line=None):
"""Show Idle-format warning after replacing warnings.showwarning.
The only difference is the formatter called.
"""
if file is None:
file = sys.stderr
try:
file.write(PyShell.idle_formatwarning(message, category, filename, lineno, line))
except IOError:
pass # the file (probably stderr) is invalid - this warning gets lost.
示例2: test_idle_formatter
# 需要導入模塊: from idlelib import PyShell [as 別名]
# 或者: from idlelib.PyShell import idle_formatwarning [as 別名]
def test_idle_formatter(self):
# Will fail if format changed without regenerating idlemsg
s = shell.idle_formatwarning(
'Test', UserWarning, 'test_warning.py', 99, 'Line of code')
self.assertEqual(idlemsg, s)
示例3: test_idle_formatter
# 需要導入模塊: from idlelib import PyShell [as 別名]
# 或者: from idlelib.PyShell import idle_formatwarning [as 別名]
def test_idle_formatter(self):
s = shell.idle_formatwarning('Test', UserWarning, 'test_warning.py', 99, 'Line of code')
self.assertEqual(idlemsg, s)