Files
panda3d/tests/linmath/test_lvector2.py
Leandro (Cerberus1746) Benedet Garcia 12f8363284 linmath: support round(), floor(), ceil() in vector classes
Closes #821
2019-12-30 03:06:00 +01:00

31 lines
864 B
Python

from math import floor, ceil
import sys
import pytest
from panda3d.core import Vec2
original_vector = Vec2(2.3, -2.6)
reason = '''Rounding in Python 2.7 expects to return a float value, since it returns a Vector it
does not work. When Python 2.7 gets deprecated, remove this check.'''
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_round():
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_floor():
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
@pytest.mark.skipif(sys.version_info < (3, 5), reason=reason)
def test_ceil():
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2