Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LoggedModel.thread.request not being cleared in failing tests #1727

Merged

Conversation

richardebeling
Copy link
Member

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 a baker.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.

@niklasmohrin
Copy link
Member

In the exception handling for responses, I found that there is a setting DEBUG_PROPAGATE_EXCEPTIONS which is read in handle_uncaught_exception in core.handlers.exception and re-raises. Webtest activates this setting WebtestMixin._patch_settings

@richardebeling richardebeling merged commit 0eec302 into e-valuation:main Mar 28, 2022
@richardebeling richardebeling deleted the del-loggedmodel-thread-request branch March 28, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants