Skip to content

Commit 8bbb0db

Browse files
committed
Work on tests
1 parent e3b80a8 commit 8bbb0db

11 files changed

+35
-8
lines changed

arcade/application.py

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def __init__(
170170
desired_gl_provider = "gl"
171171
if is_pyodide():
172172
gl_api = "webgl"
173+
174+
if gl_api == "webgl":
173175
desired_gl_provider = "webgl"
174176

175177
# Detect Raspberry Pi and switch to OpenGL ES 3.1

arcade/gl/backends/gl/framebuffer.py

-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ def __init__(
100100
if self._ctx.gc_mode == "auto" and not self.is_default:
101101
weakref.finalize(self, GLFramebuffer.delete_glo, ctx, fbo_id)
102102

103-
self.ctx.stats.incr("framebuffer")
104-
105103
def __del__(self):
106104
# Intercept garbage collection if we are using Context.gc()
107105
if self._ctx.gc_mode == "context_gc" and not self.is_default and self._glo.value > 0:

arcade/gl/backends/gl/texture_array.py

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def __init__(
126126
compressed: bool = False,
127127
compressed_data: bool = False,
128128
):
129+
super().__init__(ctx, size, components=components, dtype=dtype, data=data, filter=filter, wrap_x=wrap_x, wrap_y=wrap_y, depth=depth, samples=samples, immutable=immutable, internal_format=internal_format, compressed=compressed, compressed_data=compressed_data)
129130
self._glo = glo = gl.GLuint()
130131

131132
# Default filters for float and integer textures

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ norecursedirs = [
136136
"dist",
137137
"tempt",
138138
]
139+
markers = [
140+
"backendgl: Run OpenGL (or OpenGL ES) backend specific tests",
141+
"backendwebgl: Run WebGL backend specific tests"
142+
]
139143

140144
[tool.pyright]
141145
include = ["arcade"]

tests/conftest.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,33 @@
2626
FIXTURE_ROOT = PROJECT_ROOT / "tests" / "fixtures"
2727
arcade.resources.add_resource_handle("fixtures", FIXTURE_ROOT)
2828
REAL_WINDOW_CLASS = arcade.Window
29+
GL_BACKEND = "gl"
2930
WINDOW = None
3031
OFFSCREEN = None
3132

33+
POSSIBLE_BACKENDS = [
34+
"backendgl",
35+
"backendwebgl"
36+
]
37+
3238
arcade.resources.load_kenney_fonts()
3339

3440

41+
def pytest_addoption(parser):
42+
parser.addoption("--gl-backend", default="gl")
43+
44+
def pytest_configure(config):
45+
global GL_BACKEND
46+
GL_BACKEND = config.option.gl_backend
47+
48+
def pytest_collection_modifyitems(config, items):
49+
desired_backend = "backend" + GL_BACKEND
50+
for item in items:
51+
for backend in POSSIBLE_BACKENDS:
52+
if backend in item.keywords:
53+
if backend != desired_backend:
54+
item.add_marker(pytest.mark.skip(f"Skipping GL backend specific test for {backend}"))
55+
3556
def make_window_caption(request=None, prefix="Testing", sep=" - ") -> str:
3657
"""Centralizes test name customization.
3758
@@ -51,7 +72,7 @@ def create_window(width=1280, height=720, caption="Testing", **kwargs):
5172
global WINDOW
5273
if not WINDOW:
5374
WINDOW = REAL_WINDOW_CLASS(
54-
width=width, height=height, title=caption, vsync=False, antialiasing=False
75+
width=width, height=height, title=caption, vsync=False, antialiasing=False, gl_api = GL_BACKEND
5576
)
5677
WINDOW.set_vsync(False)
5778
# This value is being monkey-patched into the Window class so that tests can identify if we are using

tests/unit/gl/__init__.py

Whitespace-only changes.

tests/unit/gl/backends/__init__.py

Whitespace-only changes.

tests/unit/gl/backends/gl/__init__.py

Whitespace-only changes.

tests/unit/gl/test_gl_program.py renamed to tests/unit/gl/backends/gl/test_gl_program.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from pyglet import gl
55
from pyglet.math import Mat4, Mat3
66
from arcade.gl import ShaderException
7-
from arcade.gl.uniform import UniformBlock
8-
from arcade.gl.glsl import ShaderSource
7+
from arcade.gl.backends.gl.uniform import UniformBlock
8+
from arcade.gl.backends.gl.glsl import ShaderSource
99

10+
pytestmark = pytest.mark.backendgl
1011

1112
def test_shader_source(ctx):
1213
"""Test shader source parsing"""

tests/unit/gl/test_gl_context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_enable_disable(ctx):
7777
assert ctx.is_enabled(ctx.BLEND) is False
7878
assert len(ctx._flags) == 2
7979

80-
ctx.enable_only(ctx.BLEND, ctx.CULL_FACE, ctx.DEPTH_TEST, ctx.PROGRAM_POINT_SIZE)
80+
ctx.enable_only(ctx.BLEND, ctx.CULL_FACE, ctx.DEPTH_TEST)
8181

8282

8383
def test_enabled(ctx):

tests/unit/gl/test_gl_texture.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def test_properties(ctx):
2626
with pytest.raises(ValueError):
2727
texture.filter = None
2828

29-
texture.wrap_x = ctx.CLAMP_TO_BORDER
29+
texture.wrap_x = ctx.CLAMP_TO_EDGE
3030
texture.wrap_y = ctx.CLAMP_TO_EDGE
31-
assert texture.wrap_x == ctx.CLAMP_TO_BORDER
31+
assert texture.wrap_x == ctx.CLAMP_TO_EDGE
3232
assert texture.wrap_y == ctx.CLAMP_TO_EDGE
3333

3434

0 commit comments

Comments
 (0)