Skip to main content
prompt GP ChatGPT

Pytest taste — ChatGPT prompt for pytest testing

Pytest taste is a ChatGPT prompt that sets conventions for Python tests written with pytest. It guides test structure, fixtures, assertions, and suite configuration.

CC0-1.0 ★ 178,201 updated 2026-10-24

Open on GitHub

What Pytest taste does

Pytest taste lays out a testing style for Python packages: use plain assert, keep tests in a top-level tests/ directory, and put pytest settings in pyproject.toml. It favors small fixtures in the closest conftest.py and readable ids for @pytest.mark.parametrize cases.

The prompt recommends checking exception messages with pytest.raises(..., match=...), using tmp_path and monkeypatch, and replacing HTTP calls at the application boundary. Tests should not reach external services by default; integration tests run separately from the fast suite.

For async tests, it names pytest-asyncio and anyio in strict mode. It also suggests pytest-xdist for parallel runs and pytest-cov for coverage; these are recommendations, not required dependencies for the prompt.

What it helps with

  • organize tests to mirror a Python package
  • replace test loops with parametrized cases
  • check exception messages as well as types
  • keep tests from reaching external services
  • separate integration tests from the fast suite

Example prompts for the agent

  • Write pytest tests for this Python module using Pytest taste.
  • Move the pytest settings into pyproject.toml and organize the test folders.
  • Rewrite this test with fixtures and @pytest.mark.parametrize.

How to install Pytest taste

How to use

Paste the text at the start of a chat or into project instructions

Questions about Pytest taste

How do I install Pytest taste in Claude Code?

Add the prompt file at .claude/commands/prompts.csv.md.

What does Pytest taste do?

It sets conventions for pytest suites, including test layout, fixtures, exception checks, and isolation from external services.

How does Pytest taste recommend configuring pytest?

Keep settings in pyproject.toml, enable --strict-markers and --strict-config, and treat warnings as errors while allowing known third-party warnings explicitly.

Source text

prompts.csv · CC0-1.0
# Pytest taste of a Python developer who wants fast, honest test suites
- Use plain `assert` statements and let pytest's assertion rewriting explain failures instead of `unittest`-style assert methods. Confidence: 0.95
- Keep tests in a top-level `tests/` directory that mirrors the package layout, with the package installed in editable mode. Confidence: 0.85
- Configure pytest in `pyproject.toml` under `[tool.pytest.ini_options]` rather than a separate `pytest.ini` or `setup.cfg`. Confidence: 0.85
- Turn on `--strict-markers` and `--strict-config` so typos in markers or settings fail loudly. Confidence: 0.85
- Set `filterwarnings = ["error"]` and allowlist known third-party warnings explicitly, so deprecations are caught early. Confidence: 0.75
- Prefer small, composable fixtures over one giant fixture that builds the whole world. Confidence: 0.90
- Use the narrowest fixture scope that keeps tests fast; reach for `session` scope only for genuinely expensive, read-only resources. Confidence: 0.80
- Put shared fixtures in the nearest `conftest.py`, not one root conftest that every test imports implicitly. Confidence: 0.75
- Use `@pytest.mark.parametrize` with readable `ids` instead of loops inside a single test. Confidence: 0.90
- Use the built-in `tmp_path` and `monkeypatch` fixtures before writing custom temp-dir or env-var helpers. Confidence: 0.90
- Mock at the boundary (HTTP, clock, filesystem) and avoid patching internals of the code under test. Confidence: 0.85
- Use `respx`, `responses` or a fake server for HTTP instead of hand-rolled `MagicMock` chains. Confidence: 0.75
- Freeze time with `time-machine` or `freezegun` rather than sleeping or comparing against `datetime.now()`. Confidence: 0.80
- Assert on exceptions with `pytest.raises(..., match=...)` so the message is checked, not just the type. Confidence: 0.85
- Mark slow and integration tests with custom markers and run them in a separate CI job. Confidence: 0.80
- Run the suite in parallel with `pytest-xdist` once it takes more than a minute, and keep tests order-independent so that works. Confidence: 0.80
- Use `pytest-randomly` or random ordering to flush out hidden test coupling. Confidence: 0.65
- Measure coverage with `pytest-cov` and branch coverage on, but treat the number as a signal, not a target. Confidence: 0.75
- Use Hypothesis for parsers, serializers and pure functions where property-based tests find edge cases examples miss. Confidence: 0.70
- Never let tests hit real external services by default; block network access and opt in explicitly. Confidence: 0.80
- Use `pytest-asyncio` or `anyio` in strict mode for async code, never `asyncio.run` inside tests. Confidence: 0.75
- Keep each test focused on one behavior with an Arrange, Act, Assert shape and a name that reads like a sentence. Confidence: 0.85

© f · CC0-1.0 · f/prompts.chat

Similar prompts

All prompts for Testing and QA →

From the same set218

The whole set →
Makefile taste The Makefile taste ChatGPT prompt sets conventions for project Makefiles. It guides target structure, recipes, and dependencies so make can act as the project’s front door. GP ChatGPT ★ 178,201repo stars API Deprecation and Sunset Plan Builder (YAML) API Deprecation and Sunset Plan Builder (YAML) is a prompt that turns API deprecation details into a structured YAML sunset plan with timelines, communication strategies, and migration steps. GP ChatGPT ★ 178,201repo stars Nginx Config taste The Nginx Config taste ChatGPT prompt sets conventions for Nginx configuration and operations. Use it while configuring virtual hosts, HTTPS, or proxy routes. GP ChatGPT ★ 178,201repo stars Electron App taste Electron App taste is a prompt for ChatGPT, Claude.ai, and Claude Code that sets security standards for desktop apps during architecture design and Electron coding. GP ChatGPT ★ 178,201repo stars Angular App taste Angular App taste — a prompt for ChatGPT and Claude Code that enforces modern enterprise Angular architectural standards. Sets rules for standalone components, signals, and native control flow. GP ChatGPT ★ 178,201repo stars SQLite taste SQLite taste — a prompt for ChatGPT that gives practical SQLite guidance. It covers database settings, schema changes, query planning, and backups. GP ChatGPT ★ 178,201repo stars Dependency Management taste Dependency Management taste — a prompt for ChatGPT and Claude.ai that configures AI around a strict dependency management philosophy. Prevents surprise breakages. GP ChatGPT ★ 178,201repo stars Internationalization taste The Internationalization taste ChatGPT prompt sets out product internationalization practices. It covers localized UI text, data formats, and public pages. GP ChatGPT ★ 178,201repo stars

Project sponsors

Companies that keep this analytics open