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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,39 @@ jobs:
run: |
pytest -v tests

test-without-wgpu:
name: ${{ matrix.name }} without wgpu
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Test py313
os: ubuntu-latest
pyversion: '3.13'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.pyversion }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyversion }}
- name: Install package and dev dependencies
run: |
python -m pip install --upgrade pip
pip install .[tests]
pip uninstall -y wgpu
rm -r rendercanvas
- name: Unit tests
run: |
python -c "
try:
import wgpu
raise RuntimeError('wgpu could be imported, but this is the no-wgpu test build')
except ImportError:
print('wgpu is (intentionally) not available')
"
pytest -v tests

test-examples-build:
name: Test examples ${{ matrix.pyversion }}
runs-on: ${{ matrix.os }}
Expand Down
11 changes: 7 additions & 4 deletions tests/test_context.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import numpy as np
from rendercanvas.utils.bitmappresentadapter import BitmapPresentAdapter
from rendercanvas.utils.bitmaprenderingcontext import BitmapRenderingContext
from rendercanvas.offscreen import OffscreenRenderCanvas as ManualOffscreenRenderCanvas

from testutils import can_use_wgpu_lib, run_tests
import pytest


from rendercanvas.offscreen import OffscreenRenderCanvas as ManualOffscreenRenderCanvas
from rendercanvas.utils.bitmaprenderingcontext import BitmapRenderingContext

if can_use_wgpu_lib:
from rendercanvas.utils.bitmappresentadapter import BitmapPresentAdapter


def get_test_bitmap(width, height):
colors = [
(255, 0, 0, 255),
Expand Down
1 change: 1 addition & 0 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_namespace():
def test_deps_plain_import():
modules = get_loaded_modules("rendercanvas", 1)
assert modules == {"rendercanvas", "sniffio"}
# Note, no wgpu


@pytest.mark.skipif(sys.version_info < (3, 10), reason="Need py310+")
Expand Down
6 changes: 4 additions & 2 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import subprocess
from io import StringIO

import wgpu


class LogCaptureHandler(logging.StreamHandler):
_ANSI_ESCAPE_SEQ = re.compile(r"\x1b\[[\d;]+m")
Expand Down Expand Up @@ -62,6 +60,10 @@ def run_tests(scope):

def get_default_adapter_summary():
"""Get description of adapter, or None when no adapter is available."""
try:
import wgpu
except ImportError:
return None # wgpu not installed
try:
adapter = wgpu.gpu.request_adapter_sync()
except RuntimeError:
Expand Down