Merge ~cjwatson/launchpad:py3-unique-hex-string-text into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: a3b3f00bfa326bb708f6d0e701215f773e10fc17
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-unique-hex-string-text
Merge into: launchpad:master
Diff against target: 66 lines (+10/-8)
2 files modified
lib/lp/services/signing/tests/helpers.py (+8/-6)
lib/lp/testing/factory.py (+2/-2)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+386712@code.launchpad.net

Commit message

Make getUniqueHexString return Unicode

Description of the change

This is a better default, although some call sites do require bytes so now need to encode the return value.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/signing/tests/helpers.py b/lib/lp/services/signing/tests/helpers.py
2index 5675bc6..447f62c 100644
3--- a/lib/lp/services/signing/tests/helpers.py
4+++ b/lib/lp/services/signing/tests/helpers.py
5@@ -12,7 +12,6 @@ __all__ = [
6
7 import fixtures
8 from nacl.public import PrivateKey
9-from six import text_type
10
11 from lp.services.compat import mock
12 from lp.services.signing.interfaces.signingserviceclient import (
13@@ -49,23 +48,26 @@ class SigningServiceClientFixture(fixtures.Fixture):
14 def _generate(self, key_type, description):
15 key = bytes(PrivateKey.generate().public_key)
16 data = {
17- "fingerprint": text_type(self.factory.getUniqueHexString(40)),
18- "public-key": key}
19+ "fingerprint": self.factory.getUniqueHexString(40),
20+ "public-key": key,
21+ }
22 self.generate_returns.append((key_type, data))
23 return data
24
25 def _sign(self, key_type, fingerprint, message_name, message, mode):
26 key = bytes(PrivateKey.generate().public_key)
27- signed_msg = "signed with key_type={}".format(key_type.name)
28+ signed_msg = (
29+ "signed with key_type={}".format(key_type.name).encode("UTF-8"))
30 data = {
31 'public-key': key,
32- 'signed-message': signed_msg}
33+ 'signed-message': signed_msg,
34+ }
35 self.sign_returns.append((key_type, data))
36 return data
37
38 def _inject(self, key_type, private_key, public_key, description,
39 created_at):
40- data = {'fingerprint': text_type(self.factory.getUniqueHexString(40))}
41+ data = {'fingerprint': self.factory.getUniqueHexString(40)}
42 self.inject_returns.append(data)
43 return data
44
45diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
46index 03487e1..87ca1bc 100644
47--- a/lib/lp/testing/factory.py
48+++ b/lib/lp/testing/factory.py
49@@ -455,7 +455,7 @@ class ObjectFactory(
50 don't care.
51 :return: A hexadecimal string, with 'a'-'f' in lower case.
52 """
53- hex_number = '%x' % self.getUniqueInteger()
54+ hex_number = u'%x' % self.getUniqueInteger()
55 if digits is not None:
56 hex_number = hex_number.zfill(digits)
57 return hex_number
58@@ -4205,7 +4205,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
59 if fingerprint is None:
60 fingerprint = self.getUniqueUnicode('fingerprint')
61 if public_key is None:
62- public_key = self.getUniqueHexString(64)
63+ public_key = self.getUniqueHexString(64).encode('ASCII')
64 store = IMasterStore(SigningKey)
65 signing_key = SigningKey(
66 key_type=key_type, fingerprint=fingerprint, public_key=public_key,

Subscribers

People subscribed via source and target branches

to status/vote changes: