Merge lp:~dobey/ubuntuone-dev-tools/update-4-0 into lp:ubuntuone-dev-tools/stable-4-0

Proposed by dobey on 2012-09-11
Status: Merged
Approved by: Roberto Alsina on 2012-09-11
Approved revision: no longer in the source branch.
Merged at revision: 83
Proposed branch: lp:~dobey/ubuntuone-dev-tools/update-4-0
Merge into: lp:ubuntuone-dev-tools/stable-4-0
Diff against target: 95 lines (+20/-12)
4 files modified
ubuntuone/devtools/services/dbus.py (+6/-3)
ubuntuone/devtools/services/tests/test_squid.py (+2/-2)
ubuntuone/devtools/testcases/dbus.py (+6/-2)
ubuntuone/devtools/testing/tests/test_txwebserver.py (+6/-5)
To merge this branch: bzr merge lp:~dobey/ubuntuone-dev-tools/update-4-0
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) 2012-09-11 Approve on 2012-09-11
Review via email: mp+123759@code.launchpad.net

Commit Message

[Brian Curtin]

    - Remove usage of Exception.message as it was deprecated and removed from Python 3. Check the exception's "args" attribute for the message.
    - Sort out dbus related bytes/string differences surrounding subprocess pipes, environment variables, and a dbus API expecting a str argument regardless of version.
    - Remove byte string formatting, instead first formatting Unicode strings and then storing encoded bytes.

To post a comment you must log in.
Eric Casteleijn (thisfred) wrote :

looks good

review: Approve
83. By dobey on 2012-09-11

[Brian Curtin]

    - Remove usage of Exception.message as it was deprecated and removed from Python 3. Check the exception's "args" attribute for the message.
    - Sort out dbus related bytes/string differences surrounding subprocess pipes, environment variables, and a dbus API expecting a str argument regardless of version.
    - Remove byte string formatting, instead first formatting Unicode strings and then storing encoded bytes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/devtools/services/dbus.py'
2--- ubuntuone/devtools/services/dbus.py 2012-08-20 22:10:29 +0000
3+++ ubuntuone/devtools/services/dbus.py 2012-09-11 14:29:44 +0000
4@@ -29,6 +29,8 @@
5 # files in the program, then also delete it here.
6 """Utilities for finding and running a dbus session bus for testing."""
7
8+from __future__ import unicode_literals
9+
10 import os
11 import signal
12 import subprocess
13@@ -96,11 +98,12 @@
14 # Call wait here as under the qt4 reactor we get an error about
15 # interrupted system call if we don't.
16 sp.wait()
17- self.dbus_address = "".join(sp.stdout.readlines()).strip()
18- self.dbus_pid = int("".join(sp.stderr.readlines()).strip())
19+ self.dbus_address = b"".join(sp.stdout.readlines()).strip()
20+ self.dbus_pid = int(b"".join(sp.stderr.readlines()).strip())
21
22 if self.dbus_address != "":
23- os.environ["DBUS_SESSION_BUS_ADDRESS"] = self.dbus_address
24+ os.environ["DBUS_SESSION_BUS_ADDRESS"] = \
25+ self.dbus_address.decode("utf8")
26 else:
27 os.kill(self.dbus_pid, signal.SIGKILL)
28 raise DBusLaunchError("There was a problem launching dbus-daemon.")
29
30=== modified file 'ubuntuone/devtools/services/tests/test_squid.py'
31--- ubuntuone/devtools/services/tests/test_squid.py 2012-08-21 20:10:20 +0000
32+++ ubuntuone/devtools/services/tests/test_squid.py 2012-09-11 14:29:44 +0000
33@@ -376,5 +376,5 @@
34 self.patch(self.runner, '_is_squid_running', lambda: False)
35 ex = self.assertRaises(squid.SquidLaunchError,
36 self.runner.start_service)
37- self.assertTrue(out in ex.message)
38- self.assertTrue(err in ex.message)
39+ self.assertTrue(any([out in arg.encode("utf8") for arg in ex.args]))
40+ self.assertTrue(any([err in arg.encode("utf8") for arg in ex.args]))
41
42=== modified file 'ubuntuone/devtools/testcases/dbus.py'
43--- ubuntuone/devtools/testcases/dbus.py 2012-08-21 18:51:05 +0000
44+++ ubuntuone/devtools/testcases/dbus.py 2012-09-11 14:29:44 +0000
45@@ -107,8 +107,12 @@
46
47 # Set up the main loop and bus connection
48 self.loop = DBusGMainLoop(set_as_default=True)
49- self.bus = dbus.bus.BusConnection(address_or_type=bus_address,
50- mainloop=self.loop)
51+
52+ # NOTE: The address_or_type value must remain explicitly as
53+ # str instead of anything from ubuntuone.devtools.compat. dbus
54+ # expects this to be str regardless of version.
55+ self.bus = dbus.bus.BusConnection(address_or_type=str(bus_address),
56+ mainloop=self.loop)
57
58 # Monkeypatch the dbus.SessionBus/SystemBus methods, to ensure we
59 # always point at our own private bus instance.
60
61=== modified file 'ubuntuone/devtools/testing/tests/test_txwebserver.py'
62--- ubuntuone/devtools/testing/tests/test_txwebserver.py 2012-08-21 20:55:43 +0000
63+++ ubuntuone/devtools/testing/tests/test_txwebserver.py 2012-09-11 14:29:44 +0000
64@@ -39,7 +39,8 @@
65
66 SAMPLE_KEY = b"result"
67 SAMPLE_VALUE = b"sample result"
68-SAMPLE_RESOURCE = b'{{"{0}": "{1}"}}'.format(SAMPLE_KEY, SAMPLE_VALUE)
69+SAMPLE_RESOURCE = '{{"{0}": "{1}"}}'.format(
70+ SAMPLE_KEY, SAMPLE_VALUE).encode("utf8")
71 SIMPLERESOURCE = b"simpleresource"
72 OTHER_SIMPLERESOURCE = b"othersimpleresource"
73 THROWERROR = b"throwerror"
74@@ -77,8 +78,8 @@
75 root.putChild(UNAUTHORIZED, unauthorized_resource)
76 self.server = HTTPWebServer(root)
77 self.server.start()
78- self.uri = b"http://127.0.0.1:{port}/".format(
79- port=self.server.get_port())
80+ self.uri = "http://127.0.0.1:{port}/".format(
81+ port=self.server.get_port()).encode("utf8")
82 self.addCleanup(self.server.stop)
83
84 @defer.inlineCallbacks
85@@ -134,8 +135,8 @@
86
87 def get_uri(self, server):
88 """Return the uri for the server."""
89- url = b"http://127.0.0.1:{port}/"
90- return url.format(port=server.get_port())
91+ url = "http://127.0.0.1:{port}/"
92+ return url.format(port=server.get_port()).encode("utf8")
93
94 @defer.inlineCallbacks
95 def test_single_request(self):

Subscribers

People subscribed via source and target branches

to all changes: