Merge lp:~brian.curtin/ubuntuone-dev-tools/py3-unicode-literals into lp:ubuntuone-dev-tools

Proposed by Brian Curtin on 2012-08-21
Status: Merged
Approved by: Roberto Alsina on 2012-08-22
Approved revision: 89
Merged at revision: 91
Proposed branch: lp:~brian.curtin/ubuntuone-dev-tools/py3-unicode-literals
Merge into: lp:ubuntuone-dev-tools
Diff against target: 81 lines (+14/-11)
2 files modified
ubuntuone/devtools/testing/tests/test_txwebserver.py (+11/-10)
ubuntuone/devtools/testing/txwebserver.py (+3/-1)
To merge this branch: bzr merge lp:~brian.curtin/ubuntuone-dev-tools/py3-unicode-literals
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve on 2012-08-22
Alejandro J. Cura (community) 2012-08-21 Approve on 2012-08-21
Review via email: mp+120662@code.launchpad.net

Commit Message

- Enable unicode_literals for accurate text/bytes distinction to work with Python 3

Description of the Change

Clear up some bytes/text distinctions that needed to be made for Python 3 support. Formerly explicit unicode literals are now covered by the unicode_literals future import and the names which are to be bytes are now explicit.

To post a comment you must log in.
89. By Brian Curtin on 2012-08-21

forgot to put future import back in

Alejandro J. Cura (alecu) wrote :

Looks good now.

review: Approve
Roberto Alsina (ralsina) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/devtools/testing/tests/test_txwebserver.py'
2--- ubuntuone/devtools/testing/tests/test_txwebserver.py 2012-04-17 15:53:14 +0000
3+++ ubuntuone/devtools/testing/tests/test_txwebserver.py 2012-08-21 21:38:18 +0000
4@@ -28,6 +28,7 @@
5
6 """Test the twisted webserver."""
7
8+from __future__ import unicode_literals
9
10 from twisted.internet import defer
11 from twisted.trial.unittest import TestCase
12@@ -36,13 +37,13 @@
13 from ubuntuone.devtools.testing.txwebserver import HTTPWebServer
14
15
16-SAMPLE_KEY = "result"
17-SAMPLE_VALUE = "sample result"
18-SAMPLE_RESOURCE = '{{"{0}": "{1}"}}'.format(SAMPLE_KEY, SAMPLE_VALUE)
19-SIMPLERESOURCE = "simpleresource"
20-OTHER_SIMPLERESOURCE = "othersimpleresource"
21-THROWERROR = "throwerror"
22-UNAUTHORIZED = "unauthorized"
23+SAMPLE_KEY = b"result"
24+SAMPLE_VALUE = b"sample result"
25+SAMPLE_RESOURCE = b'{{"{0}": "{1}"}}'.format(SAMPLE_KEY, SAMPLE_VALUE)
26+SIMPLERESOURCE = b"simpleresource"
27+OTHER_SIMPLERESOURCE = b"othersimpleresource"
28+THROWERROR = b"throwerror"
29+UNAUTHORIZED = b"unauthorized"
30
31 # no init
32 # pylint: disable=W0232
33@@ -76,7 +77,7 @@
34 root.putChild(UNAUTHORIZED, unauthorized_resource)
35 self.server = HTTPWebServer(root)
36 self.server.start()
37- self.uri = "http://127.0.0.1:{port}/".format(
38+ self.uri = b"http://127.0.0.1:{port}/".format(
39 port=self.server.get_port())
40 self.addCleanup(self.server.stop)
41
42@@ -104,7 +105,7 @@
43
44 def test_get_iri(self):
45 """Test getting the iri from the server."""
46- expected = u"http://127.0.0.1:{port}/"
47+ expected = "http://127.0.0.1:{port}/"
48 self.assert_url(expected)
49
50 def test_get_port(self):
51@@ -133,7 +134,7 @@
52
53 def get_uri(self, server):
54 """Return the uri for the server."""
55- url = "http://127.0.0.1:{port}/"
56+ url = b"http://127.0.0.1:{port}/"
57 return url.format(port=server.get_port())
58
59 @defer.inlineCallbacks
60
61=== modified file 'ubuntuone/devtools/testing/txwebserver.py'
62--- ubuntuone/devtools/testing/txwebserver.py 2012-04-26 11:23:19 +0000
63+++ ubuntuone/devtools/testing/txwebserver.py 2012-08-21 21:38:18 +0000
64@@ -28,6 +28,8 @@
65
66 """A tx based web server."""
67
68+from __future__ import unicode_literals
69+
70 from twisted.internet import defer, reactor, ssl
71 from twisted.protocols.policies import WrappingFactory
72 from twisted.web import server
73@@ -65,7 +67,7 @@
74
75 def get_iri(self):
76 """Build the iri for this mock server."""
77- return u"{scheme}://127.0.0.1:{port}/".format(scheme=self.scheme,
78+ return "{scheme}://127.0.0.1:{port}/".format(scheme=self.scheme,
79 port=self.get_port())
80
81 def get_port(self):

Subscribers

People subscribed via source and target branches

to all changes: