diff options
author | Timothy Elliott <tle@holymonkey.com> | 2013-03-06 16:01:06 -0800 |
---|---|---|
committer | Timothy Elliott <tle@holymonkey.com> | 2013-03-06 17:09:52 -0800 |
commit | 9b8e805afbb5a3321bbe6633e7f1051f665cd30d (patch) | |
tree | d2c607c315dab1ed3a6120ae5c7462226fd0c639 | |
parent | ab572376e3aa17dcc4b928a3040449336991f33d (diff) | |
download | webtest-9b8e805afbb5a3321bbe6633e7f1051f665cd30d.tar.gz |
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".
-rw-r--r-- | CHANGELOG.rst | 3 | ||||
-rw-r--r-- | tests/test_response.py | 16 | ||||
-rw-r--r-- | 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): <form method="POST" id="second_form"></form> </body> </html> + """, + '/html_in_anchor/': """ + <html> + <head><title>Page with HTML in an anchor tag</title></head> + <body> + <a href='/foo/'>Foo Bar<span class='baz qux'>Quz</span></a> + </body> + </html> """ } @@ -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) |