Skip to content

Commit

Permalink
Unicodify the return value of TwillTestCase.last_page()
Browse files Browse the repository at this point in the history
inside the check_page_for_string() method.

Fix the following stacktrace during ToolShed tests:

```
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 329, in run
    testMethod()
  File "/galaxy/test/shed_functional/functional/test_1160_tool_help_images.py", line 79, in test_0010_load_tool_page
    self.load_display_tool_page(repository, tool_path, changeset_revision, strings_displayed=[image_path], strings_not_displayed=[])
  File "/galaxy/test/shed_functional/base/twilltestcase.py", line 1122, in load_display_tool_page
    self.check_for_strings(strings_displayed, strings_not_displayed)
  File "/galaxy/test/functional/twilltestcase.py", line 39, in check_for_strings
    self.check_page_for_string(string)
  File "/galaxy/test/functional/twilltestcase.py", line 69, in check_page_for_string
    if page.find(patt) == -1:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 8760: ordinal not in range(128)
```
  • Loading branch information
nsoranzo committed Feb 7, 2018
1 parent 77bcca4 commit b3ea839
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/functional/twilltestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from twill.other_packages._mechanize_dist import ClientForm

from base.testcase import FunctionalTestCase # noqa: I100,I202
from galaxy.util import unicodify # noqa: I201

# Force twill to log to a buffer -- FIXME: Should this go to stdout and be captured by nose?
buffer = StringIO()
Expand Down Expand Up @@ -65,7 +66,7 @@ def check_page(self, strings_displayed, strings_displayed_count, strings_not_dis

def check_page_for_string(self, patt):
"""Looks for 'patt' in the current browser page"""
page = self.last_page()
page = unicodify(self.last_page())
if page.find(patt) == -1:
fname = self.write_temp_file(page)
errmsg = "no match to '%s'\npage content written to '%s'\npage: [[%s]]" % (patt, fname, page)
Expand Down Expand Up @@ -205,6 +206,10 @@ def json_from_url(self, url, params={}):
return loads(self.last_page())

def last_page(self):
"""
Return the last visited page (usually HTML, but can binary data as
well).
"""
return tc.browser.get_html()

def last_url(self):
Expand Down

0 comments on commit b3ea839

Please sign in to comment.