From 9b8e805afbb5a3321bbe6633e7f1051f665cd30d Mon Sep 17 00:00:00 2001 From: Timothy Elliott Date: Wed, 6 Mar 2013 16:01:06 -0800 Subject: Allow TestResponse.click() to match HTML content as well as text content. This brings TestResponse.click() in alignment with the documentation, which states that description will match "HTML and all". --- CHANGELOG.rst | 3 +-- tests/test_response.py | 16 ++++++++++++++++ webtest/response.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5a13cf1..fbd0323 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,8 +4,7 @@ News 2.0.2 (unreleased) ------------------ -- Nothing changed yet. - +* Allow TestResponse.click() to match HTML content again. 2.0.1 (2013-03-05) ------------------ diff --git a/tests/test_response.py b/tests/test_response.py index 4857d8f..c2d26b7 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -91,6 +91,14 @@ def links_app(environ, start_response):
+ """, + '/html_in_anchor/': """ + + Page with HTML in an anchor tag + + Foo BarQuz + + """ } @@ -177,6 +185,14 @@ class TestResponse(unittest.TestCase): 'Just eggs.', app.get('/').click('Click me!', index=1) ) + self.assertIn( + 'This is foo.', + app.get('/html_in_anchor/').click('baz qux') + ) + + def dont_match_anchor_tag(): + app.get('/html_in_anchor/').click('href') + self.assertRaises(IndexError, dont_match_anchor_tag) def multiple_links(): app.get('/').click('Click me!') diff --git a/webtest/response.py b/webtest/response.py index 94cc209..275bd00 100644 --- a/webtest/response.py +++ b/webtest/response.py @@ -193,7 +193,7 @@ class TestResponse(webob.Response): total_links = 0 for element in self.html.find_all(tag): el_html = str(element) - el_content = element.get_text() + el_content = element.decode_contents() attrs = element if verbose: printlog('Element: %r' % el_html) -- cgit v1.2.1