Stack Explorer

pytest-mock

Testing

Pytest plugin providing mocker fixture

8M/week → Stable

Features

mockingpytestfixturesspystub

Pros and Cons

Ventajas

  • + Simple and consistent API
  • + Automatic mock cleanup
  • + Native pytest integration
  • + Wrapper over unittest.mock
  • + Easy spy and stub
  • + Call history

Desventajas

  • - Requires pytest
  • - Can mask real problems
  • - Overuse leads to fragile tests
  • - Learning curve with complex mocking
  • - Doesn't verify contracts

Use Cases

  • External dependency mocking
  • Testing code with I/O
  • Unit isolation
  • Error simulation
  • Integration testing
  • Call verification

Tecnologías Relacionadas