Skip to content

Improve test docs for LLMs #8411

@MarcSkovMadsen

Description

@MarcSkovMadsen

Providing LLMs with the skills to quickly and robustly test Panel apps is key for LLMs to create working Panel Apps.

I do believe the current documentation of tests can be significantly improved. I will collect my experience in this Feature Request and the plan to make a Pull Request when I can find the time.

Smoke Tests

"""Smoke tests for docstring example apps in tmp/.

Each test imports the module and verifies it doesn't crash on import.
"""

import importlib
import sys
from pathlib import Path

import pytest

TMP_DIR = Path(__file__).resolve().parent.parent / "tmp"

APP_FILES = sorted(TMP_DIR.glob("app_*.py"))
APP_IDS = [p.stem for p in APP_FILES]


@pytest.fixture(autouse=True)
def _clean_module_cache():
    """Remove imported app modules after each test to avoid side-effects."""
    yield
    to_remove = [name for name in sys.modules if name.startswith("app_")]
    for name in to_remove:
        del sys.modules[name]


@pytest.mark.parametrize("app_path", APP_FILES, ids=APP_IDS)
def test_app_imports_without_error(app_path):
    """Verify the app module can be imported without raising an exception."""
    spec = importlib.util.spec_from_file_location(app_path.stem, app_path)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)

UI Test

Improvements to https://panel.holoviz.org/how_to/test/uitests.html

Coming up:

  • Start Server
  • Test with Playwright
  • Take screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    TRIAGEDefault label for untriaged issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions