test_plane.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:godot-python 作者: touilleMan 项目源码 文件源码
def test_build_from_vectors(self):
        # Can build it with int or float or nothing
        msg_tmpl = "%s vs (expected) %s (args=%s)"
        for args, expected_normal, expected_d in (
                [(), (0, 0, 0), 0],
                [(Vector3(0, 0, 0), Vector3(4, 5, 6), Vector3(7, 8, 9)), (0.40824827551841736, -0.8164965510368347, 0.40824827551841736), 0.0],
                ):
            v = Plane.build_from_vectors(*args)
            normal = (pytest.approx(v.normal.x), pytest.approx(v.normal.y), pytest.approx(v.normal.z))
            assert normal == expected_normal, msg_tmpl % (v.normal, expected_normal, args)
            assert v.d == expected_d, msg_tmpl % (v.d, expected_d, args)
        with pytest.raises(TypeError):
            Plane.build_from_vectors("a", Vector3(4, 5, 6), Vector3(7, 8, 9))
        with pytest.raises(TypeError):
            Plane.build_from_vectors(Vector3(1, 2, 3), "b", Vector3(7, 8, 9))
        with pytest.raises(TypeError):
            Plane.build_from_vectors(Vector3(1, 2, 3), Vector3(4, 5, 6), "c")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号