Fix LoggedModel.thread.request not being cleared in failing tests #1727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The deletion was not working for failing tests. This caused the setup logic for following tests to assume that the "old"
request.user
is responsible for the current change (usually abaker.make()
call), while the user object didn't even exist in the database anymore. In consequence, it caused foreign key integrity errors for tests that are totally unrelated to the actual failure.This is interesting because it contradicts (my interpretation) of the django documentation, which reads as if just running teardown code after calling
self.get_response(request)
should be fine, because there should be some wrapper that catches exceptions and turns them into 400 or 500 responses. Maybe this does not apply when running tests with our setup so we can get meaningful stack traces?Anyway, it doesn't look to me as if this would be critical for any other middleware. The language middleware might not correctly set the language cookie, but that shouldn't be an issue.