Use ExtensionTestCaseMixin instead of ExtensionTestsMixin in tests.

Review Request #11927 — Created Jan. 11, 2022 and submitted — Latest diff uploaded

Information

Djblets
release-2.x

Reviewers

This updates the entire Djblets test suite to use
ExtensionTestCaseMixin for unit tests that need to work with
extensions, instead of ExtensionTestsMixin. The former is the public
interface we provide for testing capabilities, while the latter was an
in-house, hacky, outdated, and leaky mixin used by the bulk of (but not
all of) our tests.

The main reason for this change has to do with extension state leaks.
When moving to pytest, the Python 3.10 unit tests were failing due to
an extension not having the right state when a unit test was tearing
down.

The reason behind this is that extensions and extension managers weren't
being cleaned up properly. Many tests were creationg extension managers
that never got cleaned up. Since we use weak references for extension
managers, it's possible that the old test runner was allowing them to
clear in some of the cases, but the new one wasn't. Still, the logic
wasn't reliable, and this actually influenced the behavior of some of
our tests.

The modern mixin handles cleanup properly, and gives us some utilities
for managing extension scan state, simplifying some unit tests.

The old classes are still around, but will go through a deprecation
process. This is because we actually used to use the old classes for
extension unit tests, and before I rip it out, I want to make sure we
aren't still doing that anywhere.

All unit tests pass on all supported versions of Python and Django.

Commits

Files

    Loading...