Python style guide contribute

Testing

Overview

Testing at GitLab, including in Python codebases is a core priority rather than an afterthought. It is therefore important to consider test design quality alongside feature design from the start.

Use Pytest for Python testing.

Testing levels

Before writing tests, understand the different testing levels and determine the appropriate level for your changes.

Learn more about the different testing levels, and how to decide at what level your changes should be tested.

Recommendation when mocking

  • Use unittest.mock library.
  • Mock at the right level, for example, at method call boundaries.
  • Mock external services and APIs.

Testing in Python vs. Ruby on Rails