New to Claude Skills? Learn how to install them →

Wposthog on GitHub

Web Test Setup

Free

Easily configure Python test environments in Claude Code.

Get this skill

Free · Opens the source repo

What Web Test Setup does

Web Test Setup is a skill designed for developers working in Claude Code environments where the flox tool is unavailable. This skill addresses the common issue of Python version mismatches that can occur in web testing setups. When you encounter a situation where uv sync fails due to an incompatible Python version, this skill provides a straightforward solution to download and set up the required Python version directly from the python-build-standalone repository.

The skill automates the process of detecting the necessary Python version specified in your project’s pyproject.toml file. It then retrieves the appropriate build from the python-build-standalone GitHub releases, ensuring that you have the exact version needed for your tests. This eliminates the frustration of manual version management and allows you to focus on writing and executing your tests.

In addition to setting up the correct Python version, Web Test Setup also provides guidance on installing dependencies, running tests, and configuring Docker services if required. It includes detailed instructions for setting up your environment variables and managing additional setup tasks, such as creating frontend build artifacts. This makes it an essential tool for developers looking to streamline their testing processes in Claude Code.

Overall, Web Test Setup is ideal for backend developers who need to run tests in environments with specific Python version requirements. It simplifies the setup process and helps ensure that tests run smoothly without version-related issues.

When to use it

Use this skill when you need to set up a Python test environment in Claude Code and encounter version conflicts with `uv sync`.

When not to use it

This skill is not suitable if you have access to flox or if your tests do not require a specific Python version.

What you can build with it

Setting Up Tests for New Projects

When starting a new project in Claude Code, use this skill to quickly configure the necessary Python environment for testing.

Resolving Python Version Issues

If you encounter a version mismatch error while running tests, this skill provides a quick solution to download the correct Python version.

Automating Test Environments

Integrate this skill into your workflow to automate the setup of Python test environments, saving time and reducing manual errors.

How to install Web Test Setup

View source

1. Install with the skills CLI

npx skills add posthog/posthog/setup-web-tests --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by posthog

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

Tests require environment variables defined in .github/workflows/ci-backend.yml (see the env: section at the top of the file). You can also copy .env.example to .env for local development defaults.

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

If you encounter issues with the test setup, refer to .github/workflows/ci-backend.yml for the authoritative CI configuration. This file shows:

  • 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

Frequently asked questions about Web Test Setup

Similar skills