def assert_vec(vec, x, y, z, msg=''):
"""Asserts that Vec is equal to (x,y,z)."""
# Don't show in pytest tracebacks.
__tracebackhide__ = True
# Ignore slight variations
if not vec.x == pytest.approx(x):
failed = 'x'
elif not vec.y == pytest.approx(y):
failed = 'y'
elif not vec.z == pytest.approx(z):
failed = 'z'
else:
# Success!
return
new_msg = "{!r} != ({}, {}, {})".format(vec, failed, x, y, z)
if msg:
new_msg += ': ' + msg
pytest.fail(new_msg)
评论列表
文章目录