diff options
author | Tomas Moreyra <tmoreyra@machinalis.com> | 2014-05-27 11:58:20 -0300 |
---|---|---|
committer | Tomas Moreyra <tmoreyra@machinalis.com> | 2014-05-27 11:58:20 -0300 |
commit | fa44bc02ef99253e01726a7fe652449755eb969b (patch) | |
tree | cd6aecac2d25d034e91b9033a8656c00717cd857 | |
parent | e32b98660aebf50be0d2ce10eaadd4447e4fbbe8 (diff) | |
download | webtest-fa44bc02ef99253e01726a7fe652449755eb969b.tar.gz |
Added method TestApp.set_parser_features to change the parser_features used by BeautifulSoup.
-rw-r--r-- | webtest/app.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/webtest/app.py b/webtest/app.py index 11edcdb..968cc0c 100644 --- a/webtest/app.py +++ b/webtest/app.py @@ -143,6 +143,7 @@ class TestApp(object): def __init__(self, app, extra_environ=None, relative_to=None, use_unicode=True, cookiejar=None, parser_features=None, json_encoder=None, lint=True): + if 'WEBTEST_TARGET_URL' in os.environ: app = os.environ['WEBTEST_TARGET_URL'] if isinstance(app, string_types): @@ -225,6 +226,13 @@ class TestApp(object): """ self.cookiejar.clear() + def set_parser_features(self, parser_features): + """ + Changes the parser used by BeautifulSoup. See its documentation to + know the supported parsers. + """ + self.RequestClass.ResponseClass.parser_features = parser_features + def get(self, url, params=None, headers=None, extra_environ=None, status=None, expect_errors=False, xhr=False): """ |