launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26382
[Merge] ~cjwatson/launchpad:py3-decode-view-return-values into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-decode-view-return-values into launchpad:master.
Commit message:
Decode return values of views in tests where necessary
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398392
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-decode-view-return-values into launchpad:master.
diff --git a/lib/lp/app/stories/folder.txt b/lib/lp/app/stories/folder.txt
index 91ec29f..8ebd441 100644
--- a/lib/lp/app/stories/folder.txt
+++ b/lib/lp/app/stories/folder.txt
@@ -40,7 +40,7 @@ all the traversal logic.
The view will serve the file that it traverses to.
>>> view = view.publishTraverse(view.request, 'test.txt')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
Text file
It also sets the appropriate headers for cache control on the response.
@@ -58,7 +58,7 @@ identifier.
>>> view = MyFolder(object(), FakeRequest(version="devel"))
>>> view = view.publishTraverse(view.request, 'rev6510')
>>> view = view.publishTraverse(view.request, 'image1.gif')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
GIF file
Requesting a directory raises a NotFound.
@@ -117,7 +117,7 @@ image_extensions property.
('.png', '.gif')
>>> view = view.publishTraverse(view.request, 'image2')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
PNG file
>>> print(view.request.response.getHeader('Content-Type'))
image/png
@@ -131,12 +131,12 @@ If a file without extension exists, that one will be served.
>>> view = MyImageFolder(object(), FakeRequest(version="devel"))
>>> view = view.publishTraverse(view.request, 'image3')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
Image without extension
>>> view = MyImageFolder(object(), FakeRequest(version="devel"))
>>> view = view.publishTraverse(view.request, 'image3.gif')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
Image with extension
@@ -165,14 +165,14 @@ Traversing to a file in a subdirectory will now work.
>>> view = view.publishTraverse(view.request, 'public')
>>> view = view.publishTraverse(view.request, 'subdir1')
>>> view = view.publishTraverse(view.request, 'test1.txt')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
Sub file 1
But traversing to the subdirectory itself will raise a NotFound.
>>> view = MyTree(object(), FakeRequest(version="devel"))
>>> view = view.publishTraverse(view.request, 'public')
- >>> print(view()) # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
+ >>> view() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
Traceback (most recent call last):
...
zope.publisher.interfaces.NotFound: ...
diff --git a/lib/lp/app/tests/test_services.py b/lib/lp/app/tests/test_services.py
index 75061e7..0cbaee4 100644
--- a/lib/lp/app/tests/test_services.py
+++ b/lib/lp/app/tests/test_services.py
@@ -56,9 +56,10 @@ class TestServiceFactory(TestCaseWithFactory, FakeAdapterMixin):
context, view, request = test_traverse(
'https://launchpad.test/api/devel/+services')
self.assertEqual(getUtility(IServiceFactory), context)
+ view_text = view().decode('UTF-8')
self.assertEqual(
'service_factory',
- urlparse(json.loads(view())['resource_type_link']).fragment)
+ urlparse(json.loads(view_text)['resource_type_link']).fragment)
def test_invalid_service(self):
# Test that traversal to an invalid service name fails.
diff --git a/lib/lp/registry/browser/tests/distributionmirror-views.txt b/lib/lp/registry/browser/tests/distributionmirror-views.txt
index 244f4ce..af16876 100644
--- a/lib/lp/registry/browser/tests/distributionmirror-views.txt
+++ b/lib/lp/registry/browser/tests/distributionmirror-views.txt
@@ -522,7 +522,7 @@ Any user can see the RSS for an archive mirror
>>> view = create_initialized_view(
... ubuntu, '+archivemirrors-rss', principal=user,
... server_url='http://launchpad.test/ubuntu/+archivemirrors-rss')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
<?xml version="1.0"...?>
<rss xmlns:mirror="https://launchpad.net/" version="2.0">
<channel>
@@ -555,7 +555,7 @@ Any user can see the RSS for an CD mirror
>>> view = create_initialized_view(
... ubuntu, '+cdmirrors-rss', principal=user,
... server_url='http://launchpad.test/ubuntu/+cdmirrors-rss')
- >>> print(view())
+ >>> print(view().decode('UTF-8'))
<?xml version="1.0"...?>
<rss ...
<channel>