mirror of
https://github.com/panda3d/panda3d.git
synced 2025-12-30 11:39:48 -06:00
31 lines
864 B
Python
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
|