Kinto/kinto

Unit tests should be independent

Opened this issue · 0 comments

While upgrading to pytest v8, it was discovered that our unit tests have a lot of interdependence. Creating this issue to act as an epic.

Unit tests in kinto should:

  1. Be independent of each other. We should be able to run one test module with the same test results as if we had run all tests.
  2. Not create side effects. If a test needs to create a mock or a test file, that mock or test file should be removed during teardown.

Examples of issues:

  1. Running pytest tests/test_views_version.py results in a test error because it relies on something setup in another test
  2. Several tests appear to have setUp and setUpClass methods that create test state, but no associated teardown methods that reset it

Given how extensive our test scenarios are in kinto (over 2000 at this time), this may take significant effort to research and correct all cases. We should probably do this in phases to make the PR's readable.