Skip to content

fixtures

django_spire.testing.playwright.fixtures

User = get_user_model() module-attribute

pytest_configure

Source code in django_spire/testing/playwright/fixtures.py
def pytest_configure(config: Any) -> None:
    os.environ['DJANGO_ALLOW_ASYNC_UNSAFE'] = 'true'

browser_context_args

Source code in django_spire/testing/playwright/fixtures.py
@pytest.fixture(scope='session')
def browser_context_args(browser_context_args: dict[str, Any]) -> dict[str, Any]:
    return {
        **browser_context_args,
        'no_viewport': True,
        'viewport': None,
    }

browser_type_launch_args

Source code in django_spire/testing/playwright/fixtures.py
@pytest.fixture(scope='session')
def browser_type_launch_args(browser_type_launch_args: dict[str, Any]) -> dict[str, Any]:
    return {
        **browser_type_launch_args,
        'args': ['--start-maximized'],
    }

authenticated_page

Source code in django_spire/testing/playwright/fixtures.py
@pytest.fixture
def authenticated_page(page: Page, live_server: _LiveServer, transactional_db: None) -> Page:
    User.objects.create_user(
        username='testuser',
        password='testpass123',
        is_staff=True,
        is_superuser=True
    )

    page.goto(f'{live_server.url}/admin/login/')
    page.fill('input[name="username"]', 'testuser')
    page.fill('input[name="password"]', 'testpass123')
    page.click('input[type="submit"]')
    page.wait_for_url(f'{live_server.url}/admin/')

    return page