本文整理汇总了Python中unittest.TestCase.assertLess方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertLess方法的具体用法?Python TestCase.assertLess怎么用?Python TestCase.assertLess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertLess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_player_managerCollisionEvents
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertLess [as 别名]
def test_player_managerCollisionEvents(self):
old_life = self.game.perso.life
destination = self.game.tilemap.layers['pnjs'].find('monstre')[0]
(dx, dy) = self.__calcule_delta(self.game.perso, destination)
self.game.perso.move(dx, dy)
self.game.player_stackEvents(self.game.perso,
self.game.monster_layer,
self.game.playerEvents)
self.game.player_manageCollisionEvents(self.game.perso,
self.game.playerEvents)
TestCase.assertLess(self, self.game.perso.life, old_life)
示例2: run_acceptance_test
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertLess [as 别名]
def run_acceptance_test(test_case: unittest.TestCase, model_id: str, props_to_test: list=None) -> bool:
"""
Runs the acceptance test for the given model id.
:param test_case: The unittest case.
:param model_id: The model ID to run the test for.
:return: True if successful, false or exception if not.
"""
npy_test_file = os.path.join(UCVM_MODELS_DIRECTORY, model_id, "test_" + model_id + ".npy")
ucvm_model_file = os.path.join(UCVM_MODELS_DIRECTORY, model_id, "ucvm_model.xml")
spacing = 0.05
depth = 5000
bottom_corner = {
"e": 0,
"n": 0
}
if not os.path.exists(npy_test_file) or not os.path.exists(ucvm_model_file):
return False
with open(ucvm_model_file, "r") as fd:
ucvm_model = xmltodict.parse(fd.read())
bottom_corner["e"] = \
float(ucvm_model["root"]["information"]["coverage"]["bottom-left"]["e"])
bottom_corner["n"] = \
float(ucvm_model["root"]["information"]["coverage"]["bottom-left"]["n"])
model_type = ucvm_model["root"]["information"]["type"]
arr = np.load(npy_test_file)
nums = {
"x": len(arr),
"y": len(arr[0]),
"z": len(arr[0][0])
}
sd_array = [SeismicData() for _ in range(nums["x"] * nums["y"] * nums["z"])]
counter = 0
for z in range(nums["z"]):
for y in range(nums["y"]):
for x in range(nums["x"]):
sd_array[counter].original_point = Point(bottom_corner["e"] + spacing * x,
bottom_corner["n"] + spacing * y,
0 + depth * z)
counter += 1
UCVM.query(sd_array, model_id, [model_type])
if props_to_test is None or len(props_to_test) == 0:
props_to_test = ["vp", "vs", "density"]
counter = 0
epsilon = 0.006
for z in range(nums["z"]):
for y in range(nums["y"]):
for x in range(nums["x"]):
if arr[x][y][z][0] <= 0 and sd_array[counter].velocity_properties.vp is None or \
arr[x][y][z][1] <= 0 and sd_array[counter].velocity_properties.vs is None or \
arr[x][y][z][2] <= 0 and sd_array[counter].velocity_properties.density is None:
counter += 1
continue
# This is to account for a floating point rounding issue in the CVM-S4.26 test which has the new UCVM
# thinking that the corner is in bounds and the old version thinking it's out of bounds. This version
# thinks the point is 1534.999999999 where as the old version thinks it's exactly 1535. This also fixes
# a difference whereby the old CVM-S5 extended below 50000km but the new one does not.
if (sd_array[counter].original_point.x_value == -116 and
sd_array[counter].original_point.y_value == 30.45 and model_id == "cvms426") or \
(sd_array[counter].original_point.z_value == 50000 and model_id == "cvms426"):
counter += 1
continue
if "vp" in props_to_test:
test_case.assertGreater(sd_array[counter].velocity_properties.vp / arr[x][y][z][0], 1 - epsilon)
test_case.assertLess(sd_array[counter].velocity_properties.vp / arr[x][y][z][0], 1 + epsilon)
if "vs" in props_to_test:
test_case.assertGreater(sd_array[counter].velocity_properties.vs / arr[x][y][z][1], 1 - epsilon)
test_case.assertLess(sd_array[counter].velocity_properties.vs / arr[x][y][z][1], 1 + epsilon)
if "density" in props_to_test:
test_case.assertGreater(sd_array[counter].velocity_properties.density / arr[x][y][z][2],
1 - epsilon)
test_case.assertLess(sd_array[counter].velocity_properties.density / arr[x][y][z][2], 1 + epsilon)
counter += 1
return True