← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-remove-unnecessary-encoding into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-remove-unnecessary-encoding into launchpad:master.

Commit message:
Remove unnecessary encoding in various tests

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397619

This resulted in bytes on Python 3, which is much less doctest-friendly.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-remove-unnecessary-encoding into launchpad:master.
diff --git a/lib/lp/app/widgets/doc/launchpad-radio-widget.txt b/lib/lp/app/widgets/doc/launchpad-radio-widget.txt
index ef2b8e8..ac23c43 100644
--- a/lib/lp/app/widgets/doc/launchpad-radio-widget.txt
+++ b/lib/lp/app/widgets/doc/launchpad-radio-widget.txt
@@ -25,7 +25,7 @@ buttons inside.
 
     >>> html = BeautifulSoup(radio_widget())
     >>> for label in html.findAll('label'):
-    ...     print(label.encode_contents(formatter='html'))
+    ...     print(label.decode_contents(formatter='html'))
     <input checked="checked" class="radioType" id="field.branch_type.0"
            name="field.branch_type" type="radio" value="HOSTED"/>&nbsp;Hosted
     <input class="radioType" id="field.branch_type.1" name="field.branch_type"
diff --git a/lib/lp/app/widgets/tests/test_suggestion.py b/lib/lp/app/widgets/tests/test_suggestion.py
index b50973b..e1b897d 100644
--- a/lib/lp/app/widgets/tests/test_suggestion.py
+++ b/lib/lp/app/widgets/tests/test_suggestion.py
@@ -137,12 +137,8 @@ class TestSuggestionWidget(TestCaseWithFactory):
              <input type="text" value="" ...
              onKeyPress="selectWidget(&#x27;field.test_field.1&#x27;, event);"
              .../>...""")
-
-        # XXX wallyworld 2011-04-18 bug=764170: We cannot pass an unencoded
-        # unicode string to the DocTestMatcher
-        markup = markups[1].encode('utf-8')
         self.assertThat(
-            markup, DocTestMatches(expected_item_1, self.doctest_opts))
+            markups[1], DocTestMatches(expected_item_1, self.doctest_opts))
 
 
 def make_target_branch_widget(branch):
diff --git a/lib/lp/blueprints/stories/sprints/xx-sprints.txt b/lib/lp/blueprints/stories/sprints/xx-sprints.txt
index 856c9fb..f1b0ced 100644
--- a/lib/lp/blueprints/stories/sprints/xx-sprints.txt
+++ b/lib/lp/blueprints/stories/sprints/xx-sprints.txt
@@ -382,7 +382,7 @@ Now, Sample Person should be listed as an attendee.
     ...     """Print the attendees listed in the attendees portlet."""
     ...     attendees_portlet = find_portlet(sprint_page, 'Attendees')
     ...     for li in attendees_portlet.findAll('ul')[0].findAll('li'):
-    ...         print(li.a.string.encode('ascii', 'xmlcharrefreplace'))
+    ...         print(li.a.string)
 
     >>> print_attendees(browser.contents)
     Sample Person
@@ -441,7 +441,7 @@ Sample Person registers Salgado as well.
 And verifies that Carlos and Salgado are now listed:
 
     >>> print_attendees(browser.contents)
-    Carlos Perell&#243; Mar&#237;n
+    Carlos Perelló Marín
     Guilherme Salgado
     Sample Person
 
diff --git a/lib/lp/bugs/browser/tests/buglinktarget-views.txt b/lib/lp/bugs/browser/tests/buglinktarget-views.txt
index 86e5baf..192d936 100644
--- a/lib/lp/bugs/browser/tests/buglinktarget-views.txt
+++ b/lib/lp/bugs/browser/tests/buglinktarget-views.txt
@@ -144,7 +144,7 @@ We will give bug #2 a very bad title, then link the cve to the bug.
 The notification contains the escaped bug title.
 
     >>> for notification in request.response.notifications:
-    ...     print(notification.message.encode('utf8'))
+    ...     print(notification.message)
     Added link to bug #2:
     ...&lt;script&gt;window.alert(&quot;Hello!&quot;)&lt;/script&gt;....
 
diff --git a/lib/lp/code/stories/branches/xx-branch-index.txt b/lib/lp/code/stories/branches/xx-branch-index.txt
index 2ff7c1c..2d03fcb 100644
--- a/lib/lp/code/stories/branches/xx-branch-index.txt
+++ b/lib/lp/code/stories/branches/xx-branch-index.txt
@@ -76,7 +76,7 @@ than the text of the revision author.
     ...     revisions = find_tags_by_class(
     ...         browser.contents, 'revision-details')
     ...     for revision in revisions:
-    ...         print(extract_text(revision).encode('ascii'))
+    ...         print(extract_text(revision))
 
     >>> print_revisions(user_browser)
     5. By Eric on 2007-01-05
diff --git a/lib/lp/registry/doc/sourcepackage.txt b/lib/lp/registry/doc/sourcepackage.txt
index c712f3b..7c23e6d 100644
--- a/lib/lp/registry/doc/sourcepackage.txt
+++ b/lib/lp/registry/doc/sourcepackage.txt
@@ -91,7 +91,7 @@ A source package has a name, displayname, title, and a summary.
     >>> print firefox_warty.displayname
     mozilla-firefox in Ubuntu Warty
 
-    >>> print firefox_warty.title.encode('ascii', 'ignore')
+    >>> print(firefox_warty.title)
     mozilla-firefox source package in Warty
 
     >>> print firefox_warty.summary
diff --git a/lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt b/lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt
index 3f7281a..2cd9e99 100644
--- a/lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt
+++ b/lib/lp/registry/stories/person/xx-person-editgpgkeys-invalid-key.txt
@@ -74,12 +74,12 @@ will create login tokens for the revoked and expired test keys:
     ...     person, 'test@xxxxxxxxxxxxx', 'test@xxxxxxxxxxxxx',
     ...     LoginTokenType.VALIDATEGPG,
     ...     '84D205F03E1E67096CB54E262BE83793AACCD97C')
-    >>> revoked_key_token = logintoken.token.encode('ascii')
+    >>> revoked_key_token = logintoken.token
     >>> logintoken = tokenset.new(
     ...     person, 'test@xxxxxxxxxxxxx', 'test@xxxxxxxxxxxxx',
     ...     LoginTokenType.VALIDATEGPG,
     ...     '0DD64D28E5F41138533495200E3DB4D402F53CC6')
-    >>> expired_key_token = logintoken.token.encode('ascii')
+    >>> expired_key_token = logintoken.token
     >>> logout()
 
 
diff --git a/lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt b/lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt
index d002d4e..2f9de6a 100644
--- a/lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt
+++ b/lib/lp/soyuz/stories/distribution/xx-distribution-packages.txt
@@ -19,7 +19,7 @@ This page is used to search packages in a distribution context.
     'http://localhost/ubuntu/+search?text=pmount'
 
     >>> for tag in find_tags_by_class(browser.contents, 'package-matches'):
-    ...     print(extract_text(tag).encode('us-ascii', 'replace'))
+    ...     print(extract_text(tag))
     pmount
     (Matching binaries: pmount.)
 
@@ -56,7 +56,7 @@ Now run a search for mozilla-firefox and check that it is found:
     >>> field.value = 'mozilla-firefox'
     >>> browser.getControl('Search', index=0).click()
     >>> for tag in find_tags_by_class(browser.contents, 'package-matches'):
-    ...     print(extract_text(tag).encode('us-ascii', 'replace'))
+    ...     print(extract_text(tag))
     mozilla-firefox
     The Mozilla Firefox web browser
     (Matching binaries: mozilla-firefox, mozilla-firefox-data.)
diff --git a/lib/lp/translations/stories/standalone/xx-person-activity.txt b/lib/lp/translations/stories/standalone/xx-person-activity.txt
index 67e6f02..3e8640e 100644
--- a/lib/lp/translations/stories/standalone/xx-person-activity.txt
+++ b/lib/lp/translations/stories/standalone/xx-person-activity.txt
@@ -77,6 +77,6 @@ encoded link to a filtered PO file page.
 
 Because of this, the link actually works.
 
-    >>> user_browser.open(url.encode('ascii'))
+    >>> user_browser.open(url)
     >>> print(user_browser.title)
     Translations by A+b in...Serbian (sr) translation...
diff --git a/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt b/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt
index 4fca5f4..f4ce694 100644
--- a/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt
+++ b/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt
@@ -428,7 +428,7 @@ suggestions.
     >>> user_browser.getLink("Previous").click()
 
     >>> text = extract_text(find_main_content(user_browser.contents))
-    >>> print(text.encode('UTF-8'))
+    >>> print(text)
     Translating...
     English: current addressbook folder
     Current Chinese (China): (no translation yet)
diff --git a/lib/lp/translations/stories/translations/xx-translations.txt b/lib/lp/translations/stories/translations/xx-translations.txt
index 68424f7..37ba257 100644
--- a/lib/lp/translations/stories/translations/xx-translations.txt
+++ b/lib/lp/translations/stories/translations/xx-translations.txt
@@ -264,7 +264,7 @@ has the right filter preselected.
     >>> print(extract_text(untranslated))
     15
     >>> untranslated_link = extract_link_from_tag(untranslated, base_href)
-    >>> browser.open(untranslated_link.encode('UTF-8'))
+    >>> browser.open(untranslated_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=untranslated'
     >>> print(browser.getControl(name='show', index=1).value)
@@ -277,7 +277,7 @@ with the 'with new suggestions' filter selected.
     >>> print(extract_text(unreviewed))
     1
     >>> unreviewed_link = extract_link_from_tag(unreviewed, base_href)
-    >>> browser.open(unreviewed_link.encode('UTF-8'))
+    >>> browser.open(unreviewed_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=new_suggestions'
     >>> print(browser.getControl(name='show', index=1).value)
@@ -290,7 +290,7 @@ The number of updated entries points to the translation page with the
     >>> print(extract_text(updated))
     1
     >>> updated_link = extract_link_from_tag(updated, base_href)
-    >>> browser.open(updated_link.encode('UTF-8'))
+    >>> browser.open(updated_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=changed_in_ubuntu'
     >>> print(browser.getControl(name='show', index=1).value)
@@ -437,7 +437,7 @@ the right filter preselected.
     >>> print(extract_text(untranslated))
     15
     >>> untranslated_link = extract_link_from_tag(untranslated, base_href)
-    >>> browser.open(untranslated_link.encode('UTF-8'))
+    >>> browser.open(untranslated_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=untranslated'
     >>> print(browser.getControl(name='show', index=2).value)
@@ -450,7 +450,7 @@ with the 'with new suggestions' filter selected.
     >>> print(extract_text(unreviewed))
     1
     >>> unreviewed_link = extract_link_from_tag(unreviewed, base_href)
-    >>> browser.open(unreviewed_link.encode('UTF-8'))
+    >>> browser.open(unreviewed_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=new_suggestions'
     >>> print(browser.getControl(name='show', index=2).value)
@@ -463,7 +463,7 @@ The number of updated entries points to the translation page with the
     >>> print(extract_text(updated))
     1
     >>> updated_link = extract_link_from_tag(updated, base_href)
-    >>> browser.open(updated_link.encode('UTF-8'))
+    >>> browser.open(updated_link)
     >>> browser.url
     'http://translations.launchpad.test/ubuntu/hoary/+source/evolution/+pots/evolution-2.2/es/+translate?show=changed_in_ubuntu'
     >>> print(browser.getControl(name='show', index=2).value)