Skip to content

Commit 746a32e

Browse files
committed
Skip playwright tests if it isn't installed
1 parent 6105d51 commit 746a32e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/testapp/test_prose_editor_e2e.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
1+
import importlib.util
12
import os
23

34
import pytest
4-
from playwright.sync_api import expect
55

66
from testapp.models import ProseEditorModel
77

88

9+
# Check if playwright is installed
10+
playwright_available = importlib.util.find_spec("playwright") is not None
11+
12+
# Only import playwright modules if available
13+
if playwright_available:
14+
from playwright.sync_api import expect
15+
16+
917
# Set Django async unsafe to allow database operations in tests
1018
os.environ.setdefault("DJANGO_ALLOW_ASYNC_UNSAFE", "true")
1119

20+
# Skip reason for when playwright is not available
21+
requires_playwright = pytest.mark.skipif(
22+
not playwright_available, reason="Playwright not installed, skipping browser tests"
23+
)
24+
1225

1326
@pytest.mark.django_db
1427
@pytest.mark.e2e
28+
@requires_playwright
1529
def test_prose_editor_admin_form(page, live_server):
1630
"""Test that the prose editor loads and works in the admin."""
1731
# Login first
@@ -62,6 +76,7 @@ def test_prose_editor_admin_form(page, live_server):
6276

6377
@pytest.mark.django_db
6478
@pytest.mark.e2e
79+
@requires_playwright
6580
def test_prose_editor_formatting(page, live_server):
6681
"""Test formatting functionality in the prose editor."""
6782
# Login first

0 commit comments

Comments
 (0)