本文整理汇总了Python中unittest.TestCase.assertAlmostEqual方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertAlmostEqual方法的具体用法?Python TestCase.assertAlmostEqual怎么用?Python TestCase.assertAlmostEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertAlmostEqual方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_rinex_glo_nav
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def test_parse_rinex_glo_nav(self):
navigations = parse_rinex('../../test_data/log_000.15g')
g = navigations['R03']
z1, z2 = sorted([g[0], g[1]], key=lambda x: x.date)
t1, t2 = z1.eph[8], z2.eph[8]
delta_t = dt.timedelta(seconds=t2-t1)
TestCase.assertAlmostEqual(self, delta_t.total_seconds(), 5469.878906, places=10)
示例2: test_parse_ionex
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def test_parse_ionex(self):
ionex = "../../test_data/iter_0/igsg0010.16i"
M = parse_ionex(ionex)
dttimes = [dt.datetime(2016, 1, 1, x, 00) for x in range(24)]
p = (60.1, 30.1)
correct_vals = [0.913819144802, 0.896627150059, 0.782946952107, 0.643969126833,
0.55367705622, 0.553352311325, 0.617950565843, 0.906993007108,
1.10022271455, 1.33549389609, 1.66625306657, 1.60813672016,
1.4551818746, 1.28501554961, 0.919015063122, 0.570271520356,
0.420219894161, 0.389369129134, 0.388706649548, 0.291458543284,
0.243870426367, 0.268882278182, 0.342268129559, 0.374430863963]
vals = [M(p, tt) for tt in dttimes]
for i in xrange(len(vals)):
TestCase.assertAlmostEqual(self, correct_vals[i], vals[i])
示例3: assert_velocity_properties
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def assert_velocity_properties(test_case: unittest.TestCase, data: SeismicData,
velocity_prop: VelocityProperties) -> None:
test_case.assertIsNotNone(data)
test_case.assertIsNotNone(data.velocity_properties)
test_case.assertIsNotNone(velocity_prop)
for prop in dir(data.velocity_properties):
if "_" in prop[0:1] or prop == "count" or prop == "index":
continue
if getattr(data.velocity_properties, prop) is None:
test_case.assertIsNone(getattr(velocity_prop, prop))
else:
try:
float(getattr(data.velocity_properties, prop))
test_case.assertAlmostEqual(getattr(data.velocity_properties, prop),
getattr(velocity_prop, prop), 3)
except ValueError:
test_case.assertEqual(getattr(data.velocity_properties, prop),
getattr(velocity_prop, prop))
示例4: assertAlmostEqual
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def assertAlmostEqual(self, a, b):
if isinstance(a, str):
return TestCase.assertEqual(self, a, b)
if isinstance(a, numbers.Real):
return TestCase.assertAlmostEqual(self, a, b)
if isinstance(a, dict):
a, b = sorted(a.items()), sorted(b.items())
a, b = list(a), list(b)
self.assertEqual(len(a), len(b))
all(self.assertAlmostEqual(x, y) for x, y in zip(a, b))
示例5: assertAlmostEqualFixedPrecision
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def assertAlmostEqualFixedPrecision(self, found, expected, digits = 0):
BaseTestCase.assertAlmostEqual(self, found, expected, digits)
示例6: assertAlmostEqual
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertAlmostEqual [as 别名]
def assertAlmostEqual(self, A, B, delta=None, **kws):
if delta is None:
return _TestCase.assertAlmostEqual(self, A, B, **kws)
if abs(B-A)>delta:
self.fail('%s!=%s (diff=%g)'%(A,B,abs(B-A)))