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
test leak fixes #1360
test leak fixes #1360
Conversation
…current_page`` attribute on the fake request
I'm not quite 100% sure why the self.client.get('/') is necessary, but my guess is that it sets up the URL reversal machinery the first time that the test client is used.
@@ -254,6 +254,7 @@ def get_request(self, path=None, language=None, post_data=None, enforce_csrf_che | |||
request.user = getattr(self, 'user', AnonymousUser()) | |||
request.LANGUAGE_CODE = language | |||
request._dont_enforce_csrf_checks = not enforce_csrf_checks | |||
request.current_page = page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me this looks like covering up the real issue. which is that request.current_page apparently leaked in some test to another test. Shouldn't that be fixed instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the change per se is a bad one (it makes the fake request look more like a real one). But I'll admit that it may cover the real problem. Let's try to fix that first, then merge this
I tried |
As for the current_page issue, maybe the cause is exactly the same. |
real bug for nonroot tests is that |
Yes but actually that happens only if no |
See https://github.com/ojii/django-cms/tree/get-pages-root-problem for a test that shows get_pages_root seems to be the culprit Run |
fixed in 998bceb |
Changes Unknown when pulling f0911d7 on piquadrat:feature/test-leak-fixes into * on divio:develop*. |
this fixes all the test leaks that are currently appearing
WSGIRequest
has no attributecurrent_page
This can be solved by setting the
current_page
attribute on the fake requestNonRootCase
URL reversalas @yakky pointed out in #1335, it seems to be necessary to call
client.get()
orclient.post()
before doing URL-reversal. While I'm not 100% sure why this is necessary, I guess that django only sets up the whole URL-reversal infrastructure when the client is used the first time.