Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import gc
import os
from pathlib import Path
import gc

if os.environ.get("ARCADE_PYTEST_USE_RUST"):
import arcade_accelerate # pyright: ignore [reportMissingImports]
import arcade_accelerate # pyright: ignore [reportMissingImports]
arcade_accelerate.bootstrap()

import pytest
Expand All @@ -21,6 +21,9 @@ def create_window():
if not WINDOW:
WINDOW = arcade.Window(title="Testing", vsync=False, antialiasing=False)
WINDOW.set_vsync(False)
# This value is being monkey-patched into the Window class so that tests can identify if we are using
# arcade-accelerate easily in case they need to disable something when it is enabled.
WINDOW.using_accelerate = os.environ.get("ARCADE_PYTEST_USE_RUST") # pyright: ignore
return WINDOW


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/hitbox/test_hitbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def test_create_rotatable():

rot_p = rot.get_adjusted_points()
for i, (a, b) in enumerate(zip(rot_90, rot_p)):
assert a == pytest.approx(b), f"[{i}] {a} != {b}"
assert a == pytest.approx(b, abs = 1e-6), f"[{i}] {a} != {b}"
21 changes: 15 additions & 6 deletions tests/unit/sprite/test_sprite_collision.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import arcade


Expand Down Expand Up @@ -183,10 +184,14 @@ def test_check_for_collision_with_list(window):
sprite.position = x * 50, y * 50
sl.append(sprite)

with pytest.raises(TypeError):
arcade.check_for_collision_with_list("moo", sl)
with pytest.raises(TypeError):
arcade.check_for_collision_with_list(a, "moo")
# There's no good way to perform this test with arcade-accelerate enabled.
# It causes a very different exception that without the inclusion of pyo3
# into Arcade would be next to impossible to test for in a sane way.
if not window.using_accelerate:
with pytest.raises(TypeError):
arcade.check_for_collision_with_list("moo", sl)
with pytest.raises(TypeError):
arcade.check_for_collision_with_list(a, "moo")

a.position = 100, 100
assert len(arcade.check_for_collision_with_list(a, sl)) == 1
Expand All @@ -213,8 +218,12 @@ def test_check_for_collision_with_lists(window):
sl.append(sprite)
sls.append(sl)

with pytest.raises(TypeError):
arcade.check_for_collision_with_lists("moo", sl)
# There's no good way to perform this test with arcade-accelerate enabled.
# It causes a very different exception that without the inclusion of pyo3
# into Arcade would be next to impossible to test for in a sane way.
if not window.using_accelerate:
with pytest.raises(TypeError):
arcade.check_for_collision_with_lists("moo", sl)

a.position = 100, 100
assert len(arcade.check_for_collision_with_lists(a, sls)) == 1
Expand Down