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.) |
|
|
||
| if subdomain: | ||
| http_host = "{0}.{1}".format(subdomain, http_host) | ||
| if "json" in kwargs: |
There was a problem hiding this comment.
Should be able to remove this part, since the base EnvironBuilder handles JSON.
There was a problem hiding this comment.
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.
In fact, I'm pretty sure it is a safe assumption that it's not needed. Let me go ahead and do this.
|
Looks good! Please add a changelog entry as well. |
Added a new class
flask.testing.EnvironBuilderinheriting 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