pytest logo

pytest

Open Source

Powerful Python testing framework with fixtures, parameterisation, and a rich plugin ecosystem.

Visit websiteGitHub

Pricing

Free / Open source

Type

Automation

Languages

Python

// VERDICT

Reach for pytest for essentially all Python testing - simple assertions, fixtures and parametrization with a vast plugin ecosystem. Skip it only when you must stick to stdlib unittest or aren't using Python.

Best for

The de-facto Python testing framework - concise assert-based tests, powerful fixtures, parametrization and a huge plugin ecosystem, for unit through integration testing.

Avoid when

You're not in Python, you want a built-in-only stdlib approach (unittest), or a no-code tool.

CI/CD fit

pytest CLI · plugins (coverage, xdist) · CI runner

Languages

Python

Team fit

Python teams · Unit + integration testing · QA/SDETs in Python

Setup

Easy

Maintenance

Low

Learning

Intermediate

Licence

Free / Open source

// BEST FOR

  • Concise assert-based tests (no boilerplate)
  • Powerful fixtures for setup/teardown and DI
  • Parametrization for data-driven tests
  • A huge plugin ecosystem (coverage, parallel, etc.)
  • Unit through integration testing
  • The Python community standard

// AVOID WHEN

  • You're not using Python
  • You must use stdlib unittest only
  • A no-code tool is needed
  • You want a GUI runner
  • Your tests aren't code-based
  • Minimal dependencies are mandated

// QUICK START

pip install pytest
pytest            # add pytest-cov for coverage, pytest-xdist for parallel; run in CI

// ALTERNATIVES TO CONSIDER

ToolChoose it when
AVAYou want a concurrent JS test runner instead.
TestcontainersYou need real dependencies for integration tests.
Robot FrameworkYou want keyword-driven acceptance tests in Python.

// FEATURES

  • Plain assert-based test functions — no boilerplate
  • Fixture system with scope, parametrisation, and auto-use
  • Marks for tagging, skipping, and conditional execution
  • Massive plugin ecosystem (pytest-asyncio, pytest-django, pytest-bdd)
  • Detailed introspection on assertion failures

// PROS

  • De facto Python testing standard
  • Fixtures scale better than xUnit-style setUp/tearDown
  • Plugins cover virtually every Python testing need
  • Massive community and decades of stability

// CONS

  • Magic of fixtures and conftest.py confuses newcomers
  • Plugin sprawl — easy to over-depend on community plugins
  • Not a fit outside the Python ecosystem

// EXAMPLE QA WORKFLOW

  1. Install pytest

  2. Write test_*.py with plain asserts

  3. Add fixtures for setup/teardown

  4. Parametrize for data-driven cases

  5. Run with coverage/parallel plugins in CI

  6. Gate on failures and coverage

// RELATED QA.CODES RESOURCES