← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-nickname-generation into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-nickname-generation into launchpad:master.

Commit message:
Adjust nickname generation tests for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Even though we seed the random number generator to make its behaviour deterministic, the exact details of the various random mutations still depends on the details of Python's random number generator, which may change between versions.  Adjust a few tests to handle different output on Python 3 (tested on 3.5).
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-nickname-generation into launchpad:master.
diff --git a/lib/lp/registry/doc/person.txt b/lib/lp/registry/doc/person.txt
index 744f56f..686ef2b 100644
--- a/lib/lp/registry/doc/person.txt
+++ b/lib/lp/registry/doc/person.txt
@@ -534,7 +534,7 @@ account_status is NOACCOUNT, though.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    lp.registry.interfaces.person.AlreadyConvertedException: foo-o has already been converted to a team.
+    lp.registry.interfaces.person.AlreadyConvertedException: foo-... has already been converted to a team.
 
 
 Team members
diff --git a/lib/lp/registry/tests/test_nickname.py b/lib/lp/registry/tests/test_nickname.py
index 8e08e39..dbe5c45 100644
--- a/lib/lp/registry/tests/test_nickname.py
+++ b/lib/lp/registry/tests/test_nickname.py
@@ -5,6 +5,8 @@
 
 __metaclass__ = type
 
+import sys
+
 from zope.component import getUtility
 
 from lp.registry.interfaces.person import IPersonSet
@@ -43,17 +45,26 @@ class TestNicknameGeneration(TestCaseWithFactory):
         # adding random suffixes to the required length.
         self.assertIs(None, getUtility(IPersonSet).getByName('i'))
         nick = generate_nick('i@xxxxxxxxxxx')
-        self.assertEqual('i-b', nick)
+        if sys.version_info[0] >= 3:
+            self.assertEqual('i-d', nick)
+        else:
+            self.assertEqual('i-b', nick)
 
     def test_can_create_noncolliding_nicknames(self):
         # Given the same email address, generate_nick doesn't recreate the
         # same nick once that nick is used.
         self.factory.makePerson(name='bar')
         nick = generate_nick('bar@xxxxxxxxxxx')
-        self.assertEqual('bar-3', nick)
+        if sys.version_info[0] >= 3:
+            self.assertEqual('bar-1', nick)
+        else:
+            self.assertEqual('bar-3', nick)
 
         # If we used the previously created nick and get another bar@ email
         # address, another new nick is generated.
         self.factory.makePerson(name=nick)
         nick = generate_nick('bar@xxxxxxxxxxx')
-        self.assertEqual('5-bar', nick)
+        if sys.version_info[0] >= 3:
+            self.assertEqual('3-bar', nick)
+        else:
+            self.assertEqual('5-bar', nick)