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
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def create_window(width=1280, height=720, caption="Testing", **kwargs):
gl_api=GL_BACKEND,
)
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.
# 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
7 changes: 4 additions & 3 deletions tests/doc/check_examples_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_references_in_rsts():
if filename.endswith(".rst") and filename != "index.rst":
python_example_filename_list.append(filename)
txt = Path(mypath / filename).read_text()
reference = re.findall("\.\. _(.*):", txt)
reference = re.findall(r"\.\. _(.*):", txt)
references.extend(reference)

return references
Expand All @@ -31,11 +31,12 @@ def main():
files_to_reference = get_references_in_rsts()

for reference in files_to_reference:
if not reference in references_in_index:
if reference not in references_in_index:
print(f"index.rst is missing any mention of '{reference}'")

print(
"Done with checking to make sure references in doc/examples/*.rst are in doc/examples/index.rst"
"Done with checking to make sure references in doc/examples/*.rst "
"are in doc/examples/index.rst"
)


Expand Down
1 change: 0 additions & 1 deletion tests/unit/cache/test_hit_box_cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from arcade import load_texture
from arcade.cache import HitBoxCache
from arcade import hitbox


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/camera/test_camera2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_camera2d_init_inheritance_safety(window: Window, camera_class):

def test_camera2d_init_aspect_equal_0_raises_zeroprojectiondimension(window: Window):
with pytest.raises(ZeroProjectionDimension):
camera = Camera2D(aspect=0.0)
Camera2D(aspect=0.0)


@pytest.mark.parametrize("aspect", ASPECT_RATIOS)
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/draw/test_drawing_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def test_draw_primitives(window):
# Load and draw an image to the screen
# Image from kenney.nl asset pack #1
arcade.draw_text("draw_bitmap", 483, 3, arcade.color.BLACK, 12)
texture = arcade.load_texture(":resources:images/space_shooter/playerShip1_orange.png")
scale = 0.6
# arcade.draw_texture_rectangle(540, 120, scale * texture.width,
# scale * texture.height, texture, 0)
# arcade.draw_texture_rectangle(540, 60, scale * texture.width,
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/draw/test_point_rotation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pytest
import arcade
from arcade.math import rotate_point


Expand Down
18 changes: 11 additions & 7 deletions tests/unit/gl/backends/gl/test_gl_program.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import struct
import pytest
import arcade
from pyglet.graphics.api import gl
from pyglet.math import Mat4, Mat3
from pyglet.math import Mat4
from arcade.gl import ShaderException
from arcade.gl.backends.opengl.uniform import UniformBlock
from arcade.gl.backends.opengl.glsl import ShaderSource
Expand Down Expand Up @@ -155,7 +154,12 @@ def test_program_basic(ctx):

# uniform values using byte data. struct.unpack in uniform setters will read from
# objects supporting buffer protocol like glm and numpy types
mat44_bytes = b"\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?"
mat44_bytes = (
b"\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?"
)
program["matrix"] = mat44_bytes
assert program["matrix"] == Mat4()

Expand All @@ -166,7 +170,7 @@ def test_program_basic(ctx):

def test_vertex_shader(ctx):
# Program with only vertex shader
program = ctx.program(
ctx.program(
vertex_shader="""
#version 330
in vec2 in_pos;
Expand Down Expand Up @@ -213,7 +217,7 @@ def test_geo_shader(ctx):

def test_gl_attributes(ctx):
"""Make sure built in attributes don't interfere with generic attribute detection"""
program = ctx.program(
ctx.program(
vertex_shader="""
#version 330
in vec2 pos;
Expand All @@ -226,7 +230,7 @@ def test_gl_attributes(ctx):

def test_compile_failed(ctx):
with pytest.raises(ShaderException):
program = ctx.program(
ctx.program(
vertex_shader="""
#version 330
in vec2 pos
Expand All @@ -239,7 +243,7 @@ def test_compile_failed(ctx):

def test_link_failed(ctx):
with pytest.raises(ShaderException):
program = ctx.program(
ctx.program(
vertex_shader="""
#version 330
in vec2 in_pos;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/gl/test_gl_framebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_incomplete(ctx):

def test_varying_attachment_size(ctx):
"""Varying attachment sizes not supported for now"""
fb = create(ctx, 10, 20, components=4)
create(ctx, 10, 20, components=4)
with pytest.raises(ValueError):
ctx.framebuffer(
color_attachments=[
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/gl/test_gl_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_resources(ctx: arcade.ArcadeContext):
created, freed = ctx.stats.texture
texture = ctx.texture((10, 10))
assert ctx.stats.texture == (created + 1, freed)
texture = None
del texture
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -115,7 +115,7 @@ def create_resources(ctx: arcade.ArcadeContext):
created, freed = ctx.stats.buffer
buf = ctx.buffer(reserve=1024)
assert ctx.stats.buffer == (created + 1, freed)
buf = None
del buf
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -129,7 +129,7 @@ def create_resources(ctx: arcade.ArcadeContext):
depth_attachment=ctx.depth_texture((1024, 1024)),
)
assert ctx.stats.framebuffer == (created + 1, freed)
fb = None
del fb
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -140,7 +140,7 @@ def create_resources(ctx: arcade.ArcadeContext):
created, freed = ctx.stats.program
prog = ctx.program(vertex_shader=VERTEX_SRC, fragment_shader=FRAGMENT_SRC)
assert ctx.stats.program == (created + 1, freed)
prog = None
del prog
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -152,7 +152,7 @@ def create_resources(ctx: arcade.ArcadeContext):
geo = geometry.cube()
geo.instance(ctx.program(vertex_shader=VERTEX_SRC, fragment_shader=FRAGMENT_SRC))
assert ctx.stats.vertex_array == (created + 1, freed)
geo = None
del geo
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -164,7 +164,7 @@ def create_resources(ctx: arcade.ArcadeContext):
created, freed = ctx.stats.compute_shader
compute_shader = ctx.compute_shader(source=COMPUTE_SHADER_SOURCE)
assert ctx.stats.compute_shader == (created + 1, freed)
compute_shader = None
del compute_shader
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand All @@ -175,7 +175,7 @@ def create_resources(ctx: arcade.ArcadeContext):
created, freed = ctx.stats.query
query = ctx.query()
assert ctx.stats.query == (created + 1, freed)
query = None
del query
gc.collect()
if ctx.gc_mode == "context_gc":
collected = ctx.gc()
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/gl/test_gl_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ def test_buffer_description(ctx):
types.BufferDescription(ctx.buffer(reserve=16), "4f", ["in_vert", "in_normal"])

# FIXME: Non-existing normalized attribute doesn't work
# types.BufferDescription(ctx.buffer(reserve=16), '4f', ['in_vert'], normalized=['test', 'a', 'b'])
# types.BufferDescription(
# ctx.buffer(reserve=16), '4f', ['in_vert'], normalized=['test', 'a', 'b']
# )

# Wrong buffer size. It doesn't align with the format
with pytest.raises(ValueError):
types.BufferDescription(ctx.buffer(reserve=10), "4f", ["in_vert"])


def test_buffer_padding(ctx):
descr = types.BufferDescription(
types.BufferDescription(
ctx.buffer(reserve=4 * 7 * 10),
"2f 3x4 2f",
("in_pos", "in_vel"),
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/gui/test_event_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def on_hide_view(self):
self.mng.disable()

@window.event("on_mouse_press")
def record_window(*_):
def record_window_press(*_):
events.append("Window.on_mouse_press")

@window.event("on_mouse_release")
def record_window(*_):
def record_window_release(*_):
events.append("Window.on_mouse_release")

view = MyView()
Expand All @@ -113,7 +113,8 @@ def record_window(*_):
window.dispatch_event("on_mouse_release", 100, 75, 1, 0)
window.dispatch_pending_events()
window.hide_view()
window.remove_handler("on_mouse_press", record_window)
window.remove_handler("on_mouse_press", record_window_press)
window.remove_handler("on_mouse_release", record_window_release)

assert len(events) == 3, events
assert events[0] == "UIManager.on_event(UIMousePressEvent)"
Expand Down
1 change: 0 additions & 1 deletion tests/unit/gui/test_exp_restricted_input.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from arcade.gui.experimental import UIPasswordInput
from arcade.gui.experimental.restricted_input import UIRestrictedInput, UIIntInput, UIRegexInput


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/gui/test_interactive_sprite_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import arcade
from arcade.gui import UIInteractiveSpriteWidget, UIBoxLayout
from arcade.gui.events import UIOnClickEvent, UIMousePressEvent, UIMouseReleaseEvent
from arcade.gui.events import UIOnClickEvent
from arcade.gui.widgets.layout import UIAnchorLayout

from . import record_ui_events
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/gui/test_layouting_box_ortho_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from arcade.gui.widgets.layout import _C, _box_axis_algorithm, _box_orthogonal_algorithm
from arcade.gui.widgets.layout import _C, _box_orthogonal_algorithm


def test_simple_values(window):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/gui/test_layouting_gridlayout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyglet.math import Vec2

from arcade import LBWH
from arcade.gui import UIAnchorLayout, UIBoxLayout, UIDummy, UIManager
from arcade.gui import UIAnchorLayout, UIBoxLayout, UIDummy
from arcade.gui.widgets.layout import UIGridLayout


Expand Down
1 change: 0 additions & 1 deletion tests/unit/gui/test_ninepatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def shader_math():
This is just around to debug shader math.
The shader needs to be simplified at some point.
"""
atlas_size = Vec2(8, 8)
atlas_size_uniform = 8
# 8 x x texture
uv0 = Vec2(0.0625, 0.0625) # upper_left
Expand Down
1 change: 0 additions & 1 deletion tests/unit/physics_engine/test_physics_engine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import arcade
import os

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
Expand Down
1 change: 0 additions & 1 deletion tests/unit/rect/test_rect_instances.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Callable, Any

import pytest
from pyglet.math import Vec2
from arcade.types.rect import Rect, LBWH, LRBT, XYRR, XYWH

Expand Down
1 change: 0 additions & 1 deletion tests/unit/resources/test_handles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path
import pytest
import arcade
from arcade import resources

MODULE_DIR = Path(__file__).parent.parent.resolve()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/shape_list/test_buffered_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from arcade.shape_list import (
ShapeElementList,
create_line,
create_ellipse_outline,
create_ellipse_filled,
create_ellipse_filled_with_colors,
create_rectangle_filled,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/sprite/test_sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest as pytest

import arcade
from pyglet.math import Vec2

frame_counter = 0
SPRITE_TEXTURE_FEMALE_PERSON_IDLE = arcade.load_texture(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/sprite/test_sprite_animated_walking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
import arcade

COIN_SCALE = 0.5
Expand Down
1 change: 0 additions & 1 deletion tests/unit/sprite/test_sprite_texture_animation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
import pytest
import arcade

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/spritelist/test_spatial_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def test_create():

def test_incorrect_str_input():
with pytest.raises(TypeError):
sh = SpatialHash(cell_size="10")
SpatialHash(cell_size="10")


def test_incorrect_inf_input():
with pytest.raises(TypeError):
sh = SpatialHash(cell_size=float("inf"))
SpatialHash(cell_size=float("inf"))


def test_reset():
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/spritelist/test_spritesequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def test_collective_draw(window: arcade.Window) -> None:
sprite_list2.append(_CustomSpriteSolidColor(16, 16, color=(255, 0, 0, 1)))

# It really is a SpriteList with a good type; this would not typecheck otherwise
custom_sprite: _CustomSpriteSolidColor = sprite_list2[0] # assert_type
custom_sprite: _CustomSpriteSolidColor = sprite_list2[0] # noqa: F841 assert_type

# Assert that SpriteSequence is truly covariant:
# It can be used as a common type for different types of SpriteLists.
scene: list[arcade.SpriteSequence[arcade.Sprite]] = [
sprite_list1,
sprite_list2,
]
sprite: arcade.Sprite = scene[0][0] # assert_type
sprite: arcade.Sprite = scene[0][0] # noqa: F841 assert_type

# We can collectively draw all the SpriteSequences.
for sprite_list in scene:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_arcade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from copy import copy
import logging
import arcade
from arcade import *
from arcade import * # noqa: F403 This test checks what a star import gives you


# TODO: double-check whether this is actually the right solution?
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_clock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest as pytest

from arcade.clock import Clock, FixedClock, GLOBAL_CLOCK, GLOBAL_FIXED_CLOCK
from arcade.clock import GLOBAL_CLOCK, GLOBAL_FIXED_CLOCK


def test_clock():
Expand Down
Loading
Loading