1. License
“Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction”
MIT allows use in paid and closed products; pytest usually stays a development tool and is not shipped.
github.com/pytest-dev/pytest/blob/main/LICENSE3. Used by agents' projects
Dependency in 257 public GitHub projects set up for AI coding agents that we scanned (4.1%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What pytest does
pytest is a free tool that runs small checks, called tests, on your Python code and tells you which ones fail and why. Your AI assistant writes the tests next to the code, and one command shows if a change broke something. It works for a single script as well as a large app.
What people build with it
Check prices before each release
Your shop or booking app works out totals and discounts; one test table runs every coupon case, and a wrong number stops the release.
Test file exports without mess
Code that writes receipts, reports or uploads gets a fresh empty folder for each test, so no test leaves files in your project.
Test settings without real services
Point the app at a local address or a fake payment service for one test only; pytest puts the real setting back afterwards.
Check that bad input is refused
Make sure a sign-up form or an import rejects wrong data with a clear error instead of saving it.
Run old unittest suites as they are
An older project with tests in the built-in unittest style can switch to pytest without rewriting them first.
Let the assistant check its own edits Idea
After each change your AI assistant runs the tests and reads the failure report, which shows the values that did not match, before it says the work is done.
pytest popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How pytest is used
- pytest is a dependency in 257 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (15.8% of the 1,623 Python ones), #6 of 122 in testing.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,766; those are left out of every share on this page.
- Projects that use it most often also use python-dotenv (55.6%), Pydantic (51.4%), Uvicorn (49.8%).
- It is more common in projects set up for Roo Code (10.8%) than for Gemini CLI (2.7%).
By coding agent
Often used with
More about pytest
Funding
- GitHub Sponsors: https://github.com/pytest-dev
- Tidelift: https://tidelift.com/funding/github/pypi/pytest
- Open Collective: https://opencollective.com/pytest
- thanks.dev: https://thanks.dev/u/gh/pytest-dev
- Own page: https://docs.pytest.org/en/stable/sponsor.html
- 17 GitHub sponsors
Alternatives
pytest This page
Pick Vitest when the code to test is JavaScript or TypeScript in a Vite project, not Python.
Nose is an older Python test runner built on unittest; pick it only to keep an old suite running as it is.
Get started
Tell your AI assistant
“Add pytest (pin pytest==9.2.0, Python 3.10+) as a dev dependency, write tests in tests/test_*.py for the main functions with fixtures, parametrize and tmp_path, run python -m pytest -q and fix the code until every test passes.”
Install pytest into your project's virtual environment, not into the system Python.
python3 -m venv .venv source .venv/bin/activate # on Windows: .venv\Scripts\activate pip install -U pytestWrite a file whose name starts with test_ and put plain assert lines in functions whose names start with test_.
# content of test_sample.py def func(x): return x + 1 def test_answer(): assert func(3) == 5Run pytest in the project folder; it finds the test files and prints a report for each failure.
$ pytest
Mistakes to avoid
In our run with pytest 9.2.0 the test failed with "async def functions are not natively supported" and a list of plugins.
Since pytest 9.2.0 indirect, ids and scope are keyword-only and positional use raises a TypeError.
Without an editable install pytest does not see the src folder; our demo used pythonpath = ["."] for a flat folder.
pytest 9.0 added the native TOML table but does not accept both tables at once.
Other names are not collected, so the tests silently never run.
Questions
Do I need special check functions like assertEqual?
No. You write plain Python assert lines, and pytest shows the values on both sides when one fails.
Can I use it in a commercial project?
Yes. It is under the MIT license, which allows commercial use.
How do tests get shared setup like a sample cart or a database?
Through fixtures. A test names a fixture as an argument and pytest passes in what the fixture returns.
Will my old unittest tests run?
Yes. pytest runs unittest suites without changes.
Is it still maintained?
Yes. Version 9.2.0 came out on 27 October 2026.