djblets/extensions/tests/test_extension_manager.py (Diff revision 1)Show all issues
Review Request #11927 — Created Jan. 11, 2022 and submitted
This updates the entire Djblets test suite to use
ExtensionTestCaseMixinfor 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
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
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.
E501 line too long (80 > 79 characters)
Updated the new extension middleware tests to use the new mixin.
Revision 2 (+716 -626)