Index of every page on this site: llms.txt
All skills
posthog avatar

/setup-web-tests

@028173b official
by posthogposthog/posthog41k stars
3,718
Run it yourself

Set up Python test environment in Claude Code for web where flox is unavailable. Use when you need to run backend tests and `uv sync` fails due to Python version mismatch.

Use this Skill: https://skilld.dev/gh/posthog/posthog/setup-web-tests

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈47 tokens for metadata: the name and description. ≈1.1k when used: this file.

Description uses 2.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈189 characters, or 2.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Claude Code for web — test setup

This document describes how to set up and run Python tests in a Claude Code for web environment, where flox is not available.

If you get stuck following these instructions, please bail out to the user and seek their guidance. Please suggest that they update this guide.

Problem

The project requires a specific Python version pinned in pyproject.toml (check requires-python), but:

  • Claude Code for web environments may have a different system Python version
  • uv python install <version> may fail if the version isn't yet indexed by uv
  • uv sync enforces the exact version constraint and will fail with the wrong Python version

Solution: Download Python from python-build-standalone

Download the exact version from python-build-standalone GitHub releases. The script below auto-detects the required version from pyproject.toml:

# Auto-detect the required version from pyproject.toml
REQUIRED_VERSION=$(grep requires-python pyproject.toml | grep -oP '[\d.]+')
echo "Required Python: $REQUIRED_VERSION"

# Get the latest release tag from python-build-standalone
RELEASE_TAG=$(curl -sL "https://api.github.com/repos/astral-sh/python-build-standalone/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)

# Find and download the matching build
DOWNLOAD_URL=$(curl -sL "https://api.github.com/repos/astral-sh/python-build-standalone/releases/latest" | \
  grep "browser_download_url" | grep "$REQUIRED_VERSION" | grep "x86_64-unknown-linux-gnu-install_only.tar.gz" | head -1 | cut -d'"' -f4)

mkdir -p /tmp/python-install && cd /tmp/python-install
curl -L -o python.tar.gz "$DOWNLOAD_URL"
tar -xzf python.tar.gz

# Verify
/tmp/python-install/python/bin/python3 --version

If the auto-detection doesn't find a URL (e.g., the version is too new), browse the releases page manually and look for a cpython-<version>+<tag>-x86_64-unknown-linux-gnu-install_only.tar.gz asset.

Install dependencies and run tests

cd /home/user/posthog
uv sync --python /tmp/python-install/python/bin/python3
source .venv/bin/activate

# Run a specific test (if hogli is available)
hogli test path/to/test.py::TestClass::test_method -v

# Or use pytest directly
pytest path/to/test.py::TestClass::test_method -v

# Run all tests in a directory
hogli test posthog/hogql/test/ -v

Docker Services

Most tests require backend services running. If Docker is available, start them with:

docker compose -f docker-compose.dev.yml up -d

See docker-compose.dev.yml for the full list of services and ports. Some test directories have specific service requirements documented in their own configuration files.

Hosts file setup

Tests expect certain hostnames to resolve to localhost:

echo "127.0.0.1 kafka clickhouse clickhouse-coordinator objectstorage" | sudo tee -a /etc/hosts

Environment variables

The workflow-level env: section in .depot/workflows/ci-backend.yml defines the test environment variables. For local development defaults, copy .env.example to .env.

Additional Setup

Frontend dist placeholders

Some tests require frontend build artifacts to exist (even if empty):

mkdir -p frontend/dist
touch frontend/dist/index.html
touch frontend/dist/layout.html
touch frontend/dist/exporter.html

SAML dependencies (if needed)

For SAML-related functionality:

sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl

Pytest Configuration

The pytest.ini sets:

  • pythonpath = . common
  • DJANGO_SETTINGS_MODULE = posthog.settings
  • DEBUG=1, TEST=1

Default ignores: --ignore=posthog/user_scripts --ignore=services/llm-gateway --ignore=common/ingestion/acceptance_tests

Debugging installation issues

Compare your setup with .depot/workflows/ci-backend.yml when installation fails. It defines:

  • Exact Python version used in CI
  • System dependencies installed
  • Environment variables set
  • Docker services configuration
  • Test execution commands

Limitations

  • Docker unavailable: Tests requiring services will fail without Docker
  • Network restrictions: Downloading Python requires GitHub access
  • Temporal tests: Require additional Temporal service setup

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert2mo4 checks · Risk MEDIUM
  • Gen Agent Trust Hub2mo

    This skill assists in configuring a Python testing environment for PostHog web applications when standard toolchains fail. It downloads an official standalone Python binary and requires administrative privileges to update network host configurations and install required development libraries.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: MEDIUM · 1 issue

  • Runlayer9mo

    1/1 file flagged

Signed by skilld at 028173b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month

README badge

README badge for posthog/posthog/setup-web-tests

Sets up Python test execution in Claude Code for web by downloading a pinned Python version from python-build-standalone when uv sync fails due to version mismatch. Targets PostHog's backend test suite and handles Django configuration, Docker service dependencies, and environment variable setup.

Generated from the current SKILL.md.

What Python versions does this skill support?
The skill auto-detects the required Python version from your project's pyproject.toml and downloads it from python-build-standalone. It works for versions available in that repository; very new versions may require manual lookup.
Does this work in Claude Code for web?
Yes. This skill is specifically designed for Claude Code for web environments where flox is unavailable and the system Python version may not match your project's requirements.
Do I need Docker to run tests?
Most PostHog tests require backend services (Kafka, ClickHouse, etc.) via docker-compose.dev.yml. Without Docker, tests that depend on those services will fail.
Can I use this with an existing venv?
No. The skill creates a fresh venv using the downloaded Python version and uv, then installs dependencies via `uv sync`. It does not reuse existing venvs.
What if the Python version download fails?
The skill provides a fallback: manually browse the python-build-standalone releases page and download the matching cpython build for your version, then extract it to /tmp/python-install.

Generated from the current SKILL.md. These answers refresh after source changes.