Fish Trophy

chipx86 got a fish trophy!

Fish Trophy

Fix a model contamination issue with TestModelsLoaderMixin.

Review Request #9229 — Created Sept. 28, 2017 and submitted

Information

Djblets
release-0.10.x
dfea02e...

Reviewers

A recent unit test was affected by a bug in TestModelsLoaderMixin
causing a models module to remain in Django's cache after the test suite
concluded. This only happened if a subclass defined a tests app that
already contained a models.py file. If it didn't define a specific
tests app or didn't include a models.py, then the cleanup would work
correctly, but if both were present then it would fail.

The reason for this inconsistency is that if a valid models.py didn't
exist, we'd create one and store a reference to it, which allowed us to
later remove it from the module cache. If one already existed, then
there wouldn't be a reference, so it never got removed.

The logic for this is now a bit more careful to explicitly check for a
models module and to store it. If we can't import, we then proceed to
create a module and store that. This ensures we always have a module to
work with and to clean up at the end, fixing all tests.

All unit tests pass. Before this change, some failed with unknown app
errors involving models from prior test suites.

brennie
  1. Ship It!
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (96c5e82)
Loading...