Beispiel #1
0
def test_base():
    v = Transform()
    assert type(v) == Transform
    v2 = Transform.from_basis_origin(Basis(), Vector3(1, 2, 3))
    assert type(v) == Transform
    assert v2 == Transform.from_basis_origin(Basis(), Vector3(1, 2, 3))
    assert v != v2
Beispiel #2
0
def test_equal():
    basis1 = Basis.from_euler(Vector3(1, 2, 3))
    basis2 = Basis.from_euler(Vector3(1, 2, 3))
    assert basis1 == basis2
    basis2.x = Vector3(1, 2, 3)
    assert basis1 != basis2
    basis1.x = Vector3(1, 2, 3)
    assert basis1 == basis2
    bad = Basis.from_euler(Vector3(1, 2, 4))
    assert not basis1 == bad  # Force use of __eq__
Beispiel #3
0
def test_methods(field, ret_type, params):
    v = Basis()
    # Don't test methods' validity but bindings one
    assert hasattr(v, field)
    method = getattr(v, field)
    assert callable(method)
    ret = method(*params)
    assert isinstance(ret, ret_type)
Beispiel #4
0
def test_properties(field, ret_type):
    v = Basis()
    assert hasattr(v, field)
    field_val = getattr(v, field)
    assert isinstance(field_val, ret_type)
    val = Vector3(1, 2, 3)
    setattr(v, field, val)
    field_val = getattr(v, field)
    assert field_val == val
Beispiel #5
0
def test_repr():
    v = Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9))
    assert repr(v) == "<Basis(1, 2, 3, 4, 5, 6, 7, 8, 9)>"
Beispiel #6
0
def test_bad_equal(arg):
    basis = Basis.from_euler(Vector3(1, 2, 3))
    assert basis != arg
Beispiel #7
0
def test_default():
    v = Basis()
    assert isinstance(v, Basis)
    assert v.x == Vector3(1, 0, 0)
    assert v.y == Vector3(0, 1, 0)
    assert v.z == Vector3(0, 0, 1)
Beispiel #8
0
def test_bad_init_from_rows(args):
    with pytest.raises(TypeError):
        Basis(*args)
Beispiel #9
0
def test_bad_properties(field, bad_value):
    v = Basis()
    with pytest.raises(TypeError):
        setattr(v, field, bad_value)
Beispiel #10
0
def test_init_from_rows():
    v = Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9))
    assert isinstance(v, Basis)
    assert (v.x, v.y, v.z) == (Vector3(1, 4, 7), Vector3(2, 5,
                                                         8), Vector3(3, 6, 9))
Beispiel #11
0

def test_equal():
    basis1 = Basis.from_euler(Vector3(1, 2, 3))
    basis2 = Basis.from_euler(Vector3(1, 2, 3))
    assert basis1 == basis2
    basis2.x = Vector3(1, 2, 3)
    assert basis1 != basis2
    basis1.x = Vector3(1, 2, 3)
    assert basis1 == basis2
    bad = Basis.from_euler(Vector3(1, 2, 4))
    assert not basis1 == bad  # Force use of __eq__


@pytest.mark.parametrize(
    "arg", [None, 0, "foo", Basis.from_euler(Vector3(1, 2, 4))])
def test_bad_equal(arg):
    basis = Basis.from_euler(Vector3(1, 2, 3))
    assert basis != arg


def test_repr():
    v = Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9))
    assert repr(v) == "<Basis(1, 2, 3, 4, 5, 6, 7, 8, 9)>"


@pytest.mark.parametrize(
    "field,ret_type,params",
    [
        ["inverse", Basis, ()],
        ["transposed", Basis, ()],
Beispiel #12
0
import pytest

from godot import Basis, Quat, Vector3


def test_base():
    v = Quat()
    assert type(v) == Quat


@pytest.mark.parametrize(
    "field,args",
    [
        ["from_axis_angle", (Vector3.ONE, 1.1)],
        ["from_euler", (Vector3.ONE,)],
        ["from_basis", (Basis(),)],
    ],
)
def test_inits(field, args):
    build = getattr(Quat, field)
    v = build(*args)
    assert isinstance(v, Quat)


@pytest.mark.parametrize(
    "field,args",
    [
        ["from_axis_angle", (None, 1.1)],
        ["from_euler", (None,)],
        ["from_basis", (None,)],
        ["from_axis_angle", (Vector3.ONE, None)],