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

Convert make_test_environ_builder into class (fixes #3207) #3232

Merged
merged 3 commits into from May 31, 2019

Conversation

@lordmauve
Copy link
Contributor

@lordmauve lordmauve commented May 31, 2019

Added a new class flask.testing.EnvironBuilder inheriting from werkzeug.test.EnvironBuilder.

Logic from make_test_environ_builder() moved to the constructor of that class, and changed to simply instantiate the class, while issuing a DeprecationWarning.

I did explore making json_dumps() a regular method rather than a static method, to pick up app, but if anything was expecting to call EnvironBuilder.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

@lordmauve
Copy link
Contributor Author

@lordmauve lordmauve commented May 31, 2019

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.)

Loading

flask/testing.py Outdated

if subdomain:
http_host = "{0}.{1}".format(subdomain, http_host)
if "json" in kwargs:
Copy link
Member

@davidism davidism May 31, 2019

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.

Loading

Copy link
Contributor Author

@lordmauve lordmauve May 31, 2019

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.

Loading

Copy link
Contributor Author

@lordmauve lordmauve May 31, 2019

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.

Loading

Copy link
Member

@davidism davidism May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that should work.

Loading

@davidism
Copy link
Member

@davidism davidism commented May 31, 2019

Looks good! Please add a changelog entry as well.

Loading

flask/testing.py Outdated Show resolved Hide resolved
Loading
@davidism davidism merged commit 5e15850 into pallets:master May 31, 2019
13 checks passed
Loading
@davidism davidism added this to the 1.1.0 milestone May 31, 2019
@lordmauve lordmauve deleted the environbuilder branch Jun 3, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants