Created
December 2, 2014 14:50
-
-
Save jakab922/39a14f28b91de041b4f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BaseTestClient is flask.testing.FlaskClient | |
class TestClient(BaseTestClient): | |
""" | |
Test Client. | |
""" | |
def __exit__(self, exc_type, exc_value, tb): | |
self.preserve_context = False | |
top = _request_ctx_stack.top | |
if top is not None and top.preserved: | |
pass | |
def open(self, *args, **kwargs): | |
if "data" in kwargs and not isinstance(kwargs["data"], MultiDict): | |
kwargs["data"] = testlib.form.FormData(kwargs["data"]) | |
return super(TestClient, self).open(*args, **kwargs) | |
@cachedproperty | |
def urls(self): | |
return self.application.url_map.bind("localhost", "/") | |
def url_for(self, endpoint, **kwargs): | |
return self.urls.build(endpoint, kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment