# pytest

12 Hacker News commenters recommended pytest and 5 criticized it, November 2025 to November 2026. It was recommended in 9 of 13 months. It meets the Hacker Approved badge rule.

**Verdict:** Widely used Python test runner praised for fixtures, parametrized tests and easy CI setup. Critics say fixture magic is hard to follow.

## Why people recommend it

- Runs cleanly in CI and hooks (3 comments): "I immediately set up up ruff, ty, pytest, pre-commit hook and GH workflow to run ruff/ty/pytest" ([source](https://news.ycombinator.com/item?id=46795249)) "have a test suite which runs cleanly with "uv run pytest"" ([source](https://news.ycombinator.com/item?id=46710680)) "pre-push will run pytest but with reduced output" ([source](https://news.ycombinator.com/item?id=47820143))
- Fixtures and parametrize make many tests easy (2 comments): "fixtures are often good enough for coming up with multiple tests but are simple enough to implement" ([source](https://news.ycombinator.com/item?id=45820011)) "Write pytest tests with pytest.mark.parametrize, fixtures, and mocks." ([source](https://news.ycombinator.com/item?id=48532642))
- Well represented in AI training data (2 comments): "there are a TON of good examples of pytest tests floating around in the training data" ([source](https://news.ycombinator.com/item?id=46765940)) "I've had the most success running Claude iteratively with mypy and pytest." ([source](https://news.ycombinator.com/item?id=46215740))

## What people warn about

- Awkward with non-standard project layouts (2 comments): "pytest running code from the source directory by default" ([source](https://news.ycombinator.com/item?id=49655542)) "pytest doesn't want to run this way" ([source](https://news.ycombinator.com/item?id=47614272))

## Alternatives hackers recommend

- [Mockito](https://hackerapproved.com/p/mockito.md): 19 recommend
- [cargo-nextest](https://hackerapproved.com/p/cargo-nextest.md): 18 recommend
- [Vitest](https://hackerapproved.com/p/vitest.md): 17 recommend
- [Testcontainers](https://hackerapproved.com/p/testcontainers.md): 14 recommend
- [Cucumber](https://hackerapproved.com/p/cucumber.md): 9 recommend

## Cite as

Hacker Approved, "pytest", https://hackerapproved.com/p/pytest/ (counts from 1,795,640 Hacker News comments, November 2025 to November 2026).
