setup-web-tests

Detect Python version from pyproject.toml and download a compatible interpreter for pytest workflows.

37.6k|3.2k|Updated Jan 23, 2020
One-click install
npx skills add https://github.com/PostHog/posthog --skill setup-web-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setup-web-tests
Source: https://github.com/PostHog/posthog/tree/main/.claude/skills/setup-web-tests
Command: npx skills add https://github.com/PostHog/posthog --skill setup-web-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates configuring a Python test environment in Claude Code for web when flox is unavailable, enabling backend test execution without manual setup.

Core Features & Use Cases

  • Detects the required Python version from pyproject.toml and matches it against a python-build-standalone release.
  • Downloads and installs a compatible Python interpreter, then prepares a reusable test runtime for pytest-based workflows.
  • Use cases include running backend tests for web projects where standard runtimes are unavailable or inconsistent, and validating Python compatibility across environments.

Quick Start

Follow these steps to set up and run tests in Claude Code for web:

REQUIRED_VERSION=$(grep requires-python pyproject.toml | grep -oP '[\d.]+') echo "Required Python: $REQUIRED_VERSION"

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

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

Setup and run tests

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

Run a specific test

pytest path/to/test.py::TestClass::test_method -v

Run all tests in a directory

pytest posthog/hogql/test/ -v

Frequently Asked Questions about setup-web-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a Python test environment in Claude Code when flox is unavailable?

To set up a Python test environment in Claude Code when flox is unavailable, this Skill automates detecting the required Python version from pyproject.toml and downloading a compatible interpreter from python-build-standalone. It then prepares a reusable runtime for pytest-based workflows.

How does pytest find the correct Python version from pyproject.toml?

pytest workflows use this Skill to read the requires-python field from pyproject.toml and match it against a python-build-standalone release. It downloads and installs the compatible Python interpreter to ensure the environment meets project specifications.

Can I run pytest with Docker services using this Python test setup?

Yes, you can run pytest with optional Docker services using this Python test setup. After downloading the interpreter and running uv sync, the Skill provides commands to execute specific test methods or entire directories with pytest and Docker services.

What is the best way to install a standalone Python interpreter for pytest?

The best way to install a standalone Python interpreter for pytest is using python-build-standalone releases. This Skill fetches the matching build based on your pyproject.toml requires-python field and extracts it to a temporary directory for immediate use.

Does uv sync work with a manually downloaded Python interpreter?

Yes, uv sync works with a manually downloaded Python interpreter by specifying the path to the extracted python-build-standalone binary. You point uv to the installed python3 executable, sync the environment, and activate the resulting .venv to run tests.

Why does my Python test environment setup fail without flox in Claude Code?

Your Python test environment setup fails without flox because standard runtimes are unavailable or inconsistent. This Skill solves the problem by automating the detection and installation of a compatible python-build-standalone interpreter for your web projects.