本文整理匯總了Python中test.test_support.cpython_only方法的典型用法代碼示例。如果您正苦於以下問題:Python test_support.cpython_only方法的具體用法?Python test_support.cpython_only怎麽用?Python test_support.cpython_only使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test.test_support
的用法示例。
在下文中一共展示了test_support.cpython_only方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_main
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import cpython_only [as 別名]
def test_main():
test_support.run_unittest(FormatTest)
def test_precision(self):
f = 1.2
self.assertEqual(format(f, ".0f"), "1")
self.assertEqual(format(f, ".3f"), "1.200")
with self.assertRaises(ValueError) as cm:
format(f, ".%sf" % (sys.maxsize + 1))
self.assertEqual(str(cm.exception), "precision too big")
c = complex(f)
self.assertEqual(format(c, ".0f"), "1+0j")
self.assertEqual(format(c, ".3f"), "1.200+0.000j")
with self.assertRaises(ValueError) as cm:
format(c, ".%sf" % (sys.maxsize + 1))
self.assertEqual(str(cm.exception), "precision too big")
@test_support.cpython_only
def test_precision_c_limits(self):
from _testcapi import INT_MAX
f = 1.2
with self.assertRaises(ValueError) as cm:
format(f, ".%sf" % (INT_MAX + 1))
c = complex(f)
with self.assertRaises(ValueError) as cm:
format(c, ".%sf" % (INT_MAX + 1))