pytest-integration-tests

pytest-integration-tests is a cursor rule for Cursor from iloveitaly/llm-ide-rules. It costs 0 tokens per session (1,310 once invoked), scanned A, original, MIT.

A set of rules for writing integration tests with Pytest, a Python testing tool, for a web application. Integration tests check the application through its user interface and connected services.

In plain words
What is it for?
Use it when adding or fixing browser-based tests, including database setup, page interactions, response checks, timeouts and failure screenshots.
Why use it?
It gives consistent ways to create test data, interact with pages, handle slow runs and write assertions that are less likely to break after small interface changes.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/iloveitaly/llm-ide-rules/pytest-integration-tests
Clone the repo
git clone --depth 1 https://github.com/iloveitaly/llm-ide-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytest-integration-tests

README.md
[![agentmods](https://agentmods.dev/badge/rules/iloveitaly/llm-ide-rules/pytest-integration-tests.svg)](https://agentmods.dev/rules/iloveitaly/llm-ide-rules/pytest-integration-tests)
Your own site
<a href="https://agentmods.dev/rules/iloveitaly/llm-ide-rules/pytest-integration-tests"><img src="https://agentmods.dev/badge/rules/iloveitaly/llm-ide-rules/pytest-integration-tests.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,310 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01310
Opus 5 $0.00000 $0.00655
Sonnet 5 $0.00000 $0.00262
Haiku 4.5 $0.00000 $0.00131

Measured 6d ago against content hash fcb9d4555e90, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

pytest-integration-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/pytest-integration-tests.mdc · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pytest Integration Tests

  • Look to app/factories/ to generate any required database state
    • Here's an example of how to create + persist a factory DistributionFactory.save(domain=PYTHON_TEST_SERVER_HOST)
  • Add the server factory to each test
  • Use the faker factory to generate emails, etc.
  • Don't add obvious assert descriptions
  • Do not use the db_session fixture here. Instead, use with test_session(): if you need to setup complex database state
  • if a UI timeout is occuring, it could be because it cannot find a element because the rendering has changed. Check the failure screenshot and see if you can correct the test assertion.
  • The integration tests can take a very long time to run. Do not abort them if they are taking a long time.
  • Use expect(page.get_by_text("Screening is fully booked")).to_be_visible() instead of expect(page.get_by_role("heading")).to_contain_text("Screening is fully booked"). It's less brittle.
  • Do not use client fixtures in an integration test. Integration tests should only use the frontend of the website to interact with the application, not the API.
  • Use with page.expect_response("https://example.com/resource") as response_info: to assert against network activity.
  • Do not next_button.evaluate("el => el.click()") instead, just locator.click(). If this doesn't work, stop your work and let me know.
  • Only use wait_for_loading(page) if a LONG_INTEGRATION_TEST_TIMEOUT on an expectation does not work: expect(page.get_by_text("Your Matched Doctors")).to_be_visible(timeout=LONG_INTEGRATION_TEST_TIMEOUT)
    • LONG_INTEGRATION_TEST_TIMEOUT should only be used as a last resort. If you have many of these in a test, let me know and I will debug it.
  • Prefer fewer integration tests that cover more functionality. Unlike unit tests, where each test is designed to test a very particular piece of functionality, I want integration tests to cover entire workflows. It's preferred to add more steps to an integration test to test an entire workflow.
  • Prefer simple locators. If a filter, or_, etc is required to capture a button in multiple states it indicates something is wrong in the code.
  • Use react_router_url to generate the frontend url path and do not set base_url.
  • End all Playwright tests with from pytest_playwright_artifacts import assert_no_console_errors and assert_no_console_errors(request) (capture is the plugin's playwright_console_logging fixture).
    • Test-Specific Ignores: Pass ignore=[...] to assert_no_console_errors per pytest-playwright-artifacts (regex strings, compiled patterns, or {"file": "...", "message": "..."} dicts); add a comment explaining why.
    • Global Ignores: Use playwright_console_ignore under [tool.pytest.ini_options] in pyproject.toml (see pytest-playwright-artifacts README).

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 110 lines · 0 tokens per session scan A fcb9d4555e90

Subscribe to this mod's changes

pytest-integration-tests is a cursor rule published in the GitHub repository iloveitaly/llm-ide-rules (13 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,310 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.