-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
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
Convert make_test_environ_builder into class (fixes #3207) #3232
Conversation
Tests and stylecheck passed under Tox but somehow the Azure pipelines have not been requested for this PR. (I appear to be on a dodgy internet connection.) |
flask/testing.py
Outdated
|
||
if subdomain: | ||
http_host = "{0}.{1}".format(subdomain, http_host) | ||
if "json" in kwargs: |
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.
Should be able to remove this part, since the base EnvironBuilder
handles JSON.
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.
No, because the base class doesn't know about app
and therefore does not take JSON serialisation settings from it.
This could be removed if json_dumps()
was added as a method that respects self.app
, but this is hard if json_dumps() needs to be callable as a static method as described above. If that's not needed, then yes, I can remove this.
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.
In fact, I'm pretty sure it is a safe assumption that it's not needed. Let me go ahead and do this.
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.
Yeah, that should work.
Looks good! Please add a changelog entry as well. |
Added a new class
flask.testing.EnvironBuilder
inheriting fromwerkzeug.test.EnvironBuilder
.Logic from
make_test_environ_builder()
moved to the constructor of that class, and changed to simply instantiate the class, while issuing aDeprecationWarning
.I did explore making
json_dumps()
a regular method rather than a static method, to pick upapp
, but if anything was expecting to callEnvironBuilder.json_dumps()
as a static method then this would break. Requires funky descriptor tricks to work both as a static method and an instance method under Python 2 and so didn't seem worth the code it would take.closes #3207