← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/buildmaster-tests-future-imports into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/buildmaster-tests-future-imports into lp:launchpad.

Commit message:
Convert tests under lp.buildmaster to Launchpad's preferred __future__ imports.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/buildmaster-tests-future-imports/+merge/347519
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/buildmaster-tests-future-imports into lp:launchpad.
=== modified file 'lib/lp/buildmaster/browser/tests/test_builder.py'
--- lib/lp/buildmaster/browser/tests/test_builder.py	2017-12-21 20:39:39 +0000
+++ lib/lp/buildmaster/browser/tests/test_builder.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the lp.soyuz.browser.builder module."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from zope.component import getUtility

=== modified file 'lib/lp/buildmaster/browser/tests/test_builder_views.py'
--- lib/lp/buildmaster/browser/tests/test_builder_views.py	2018-02-02 10:06:24 +0000
+++ lib/lp/buildmaster/browser/tests/test_builder_views.py	2018-06-06 11:29:12 +0000
@@ -1,6 +1,8 @@
 # Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from functools import partial

=== modified file 'lib/lp/buildmaster/browser/tests/test_processor.py'
--- lib/lp/buildmaster/browser/tests/test_processor.py	2018-01-02 16:10:26 +0000
+++ lib/lp/buildmaster/browser/tests/test_processor.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for process navigation."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from lp.services.webapp.publisher import canonical_url

=== modified file 'lib/lp/buildmaster/doc/builder.txt'
--- lib/lp/buildmaster/doc/builder.txt	2014-04-23 10:50:06 +0000
+++ lib/lp/buildmaster/doc/builder.txt	2018-06-06 11:29:12 +0000
@@ -20,11 +20,11 @@
 
     >>> from lp.testing import verifyObject
 
-    >>> print builder.name
+    >>> print(builder.name)
     bob
-    >>> print builder.builderok
+    >>> print(builder.builderok)
     True
-    >>> print builder.failnotes
+    >>> print(builder.failnotes)
     None
 
 
@@ -42,7 +42,7 @@
 Iterating over a BuilderSet yields all registered builders.
 
     >>> for b in builderset:
-    ...     print b.name
+    ...     print(b.name)
     bob
     frog
 
@@ -53,16 +53,16 @@
 
 Builders can be retrieved by name.
 
-    >>> print builderset['bob'].name
+    >>> print(builderset['bob'].name)
     bob
-    >>> print builderset['bad']
+    >>> print(builderset['bad'])
     None
 
 And also by ID.
 
-    >>> print builderset.get(2).name
+    >>> print(builderset.get(2).name)
     frog
-    >>> print builderset.get(100).name
+    >>> print(builderset.get(100).name)
     Traceback (most recent call last):
     ...
     SQLObjectNotFound: Object not found
@@ -80,7 +80,7 @@
 virtualization status, architecture, then name.
 
     >>> for b in builderset.getBuilders():
-    ...     print b.name
+    ...     print(b.name)
     bob
     dummy
     frog
@@ -88,7 +88,7 @@
     >>> bnew.active = False
     >>> login(ANONYMOUS)
     >>> for b in builderset.getBuilders():
-    ...     print b.name
+    ...     print(b.name)
     bob
     frog
 
@@ -149,5 +149,5 @@
     ...     distroseries=ubuntu.currentseries).queueBuild()
     >>> transaction.commit()
     >>> queue_sizes = builderset.getBuildQueueSizes()
-    >>> print queue_sizes['virt']['386']
+    >>> print(queue_sizes['virt']['386'])
     (1L, datetime.timedelta(0, 600))

=== modified file 'lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt'
--- lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt	2015-07-08 16:05:11 +0000
+++ lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt	2018-06-06 11:29:12 +0000
@@ -32,7 +32,7 @@
     ...     """A custom build behaviour for building blah."""
     ...
     ...     def dispatchBuildToSlave(self, logger):
-    ...         print "Did something special to dispatch MySpecialBuild."
+    ...         print("Did something special to dispatch MySpecialBuild.")
 
 For this documentation, we'll also need a dummy new build farm job.
 

=== modified file 'lib/lp/buildmaster/doc/buildqueue.txt'
--- lib/lp/buildmaster/doc/buildqueue.txt	2013-11-19 09:27:01 +0000
+++ lib/lp/buildmaster/doc/buildqueue.txt	2018-06-06 11:29:12 +0000
@@ -100,16 +100,16 @@
     >>> bob = getUtility(IBuilderSet)['bob']
     >>> job = bob.currentjob
 
-    >>> print job.builder.name
+    >>> print(job.builder.name)
     bob
     >>> job.date_started is not None
     True
-    >>> print job.logtail
+    >>> print(job.logtail)
     Dummy sampledata entry, not processing
     >>> build = getUtility(IBinaryPackageBuildSet).getByQueueEntry(job)
-    >>> print build.status.name
+    >>> print(build.status.name)
     BUILDING
-    >>> print job.lastscore
+    >>> print(job.lastscore)
     1
 
 IBuildQueue.reset() will reset the job, enabling it to be dispatched
@@ -118,20 +118,20 @@
     >>> job.reset()
 
     >>> del get_property_cache(bob).currentjob
-    >>> print bob.currentjob
+    >>> print(bob.currentjob)
     None
 
-    >>> print job.status.name
+    >>> print(job.status.name)
     WAITING
-    >>> print job.builder
-    None
-    >>> print job.date_started
-    None
-    >>> print job.logtail
-    None
-    >>> print build.status.name
+    >>> print(job.builder)
+    None
+    >>> print(job.date_started)
+    None
+    >>> print(job.logtail)
+    None
+    >>> print(build.status.name)
     NEEDSBUILD
-    >>> print job.lastscore
+    >>> print(job.lastscore)
     1
 
 On the flip-side, IBuildQueue.markAsBuilding() will assign the job to
@@ -143,11 +143,11 @@
     >>> bob.currentjob == job
     True
 
-    >>> print job.builder.name
+    >>> print(job.builder.name)
     bob
     >>> job.date_started is not None
     True
-    >>> print build.status.name
+    >>> print(build.status.name)
     BUILDING
 
 
@@ -171,5 +171,5 @@
 applications:
 
     >>> current_job = bqset.getByBuilder(bob)
-    >>> print current_job.builder.name
+    >>> print(current_job.builder.name)
     bob

=== modified file 'lib/lp/buildmaster/tests/harness.py'
--- lib/lp/buildmaster/tests/harness.py	2012-02-28 05:36:01 +0000
+++ lib/lp/buildmaster/tests/harness.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """TacHandler for `buildd-manager` daemon."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 __all__ = [

=== modified file 'lib/lp/buildmaster/tests/mock_slaves.py'
--- lib/lp/buildmaster/tests/mock_slaves.py	2018-05-14 08:15:12 +0000
+++ lib/lp/buildmaster/tests/mock_slaves.py	2018-06-06 11:29:12 +0000
@@ -3,6 +3,8 @@
 
 """Mock Build objects for tests soyuz buildd-system."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 __all__ = [

=== modified file 'lib/lp/buildmaster/tests/test_builder.py'
--- lib/lp/buildmaster/tests/test_builder.py	2018-01-10 10:45:24 +0000
+++ lib/lp/buildmaster/tests/test_builder.py	2018-06-06 11:29:12 +0000
@@ -3,6 +3,8 @@
 
 """Test Builder features."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from fixtures import FakeLogger
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy

=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjob.py'
--- lib/lp/buildmaster/tests/test_buildfarmjob.py	2018-01-02 10:54:31 +0000
+++ lib/lp/buildmaster/tests/test_buildfarmjob.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for `IBuildFarmJob`."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import (

=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py'
--- lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py	2018-05-02 13:22:17 +0000
+++ lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for BuildFarmJobBehaviourBase."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import datetime

=== modified file 'lib/lp/buildmaster/tests/test_buildmaster_documentation.py'
--- lib/lp/buildmaster/tests/test_buildmaster_documentation.py	2012-01-20 16:11:11 +0000
+++ lib/lp/buildmaster/tests/test_buildmaster_documentation.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Runs the doctests for buildmaster module."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 

=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
--- lib/lp/buildmaster/tests/test_buildqueue.py	2015-05-14 08:50:41 +0000
+++ lib/lp/buildmaster/tests/test_buildqueue.py	2018-06-06 11:29:12 +0000
@@ -1,7 +1,9 @@
-# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 """Test BuildQueue features."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from datetime import timedelta
 
 from storm.sqlobject import SQLObjectNotFound
@@ -54,7 +56,7 @@
     def processor_name(bq):
         return ('None' if bq.processor is None else bq.processor.name)
 
-    print ""
+    print("")
     queue_entries = [build.buildqueue_record for build in builds]
     queue_entries = sorted(
         queue_entries, key=lambda qe: qe.job.id, reverse=True)
@@ -65,10 +67,10 @@
             source = getattr(queue_entry.specific_build, attr, None)
             if source is not None:
                 break
-        print "%5s, %18s, p:%5s, v:%5s e:%s *** s:%5s" % (
+        print("%5s, %18s, p:%5s, v:%5s e:%s *** s:%5s" % (
             queue_entry.id, source.name, processor_name(queue_entry),
             queue_entry.virtualized, queue_entry.estimated_duration,
-            queue_entry.lastscore)
+            queue_entry.lastscore))
 
 
 class TestBuildCancellation(TestCaseWithFactory):

=== modified file 'lib/lp/buildmaster/tests/test_doc.py'
--- lib/lp/buildmaster/tests/test_doc.py	2015-09-11 13:56:38 +0000
+++ lib/lp/buildmaster/tests/test_doc.py	2018-06-06 11:29:12 +0000
@@ -1,14 +1,18 @@
-# Copyright 2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Run pagetests."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 
 from lp.services.testing import build_test_suite
+from lp.testing.systemdocs import setUp
+
 
 here = os.path.dirname(os.path.realpath(__file__))
 
 
 def test_suite():
-    return build_test_suite(here)
+    return build_test_suite(here, setUp=lambda test: setUp(test, future=True))

=== modified file 'lib/lp/buildmaster/tests/test_interactor.py'
--- lib/lp/buildmaster/tests/test_interactor.py	2017-12-19 17:22:44 +0000
+++ lib/lp/buildmaster/tests/test_interactor.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test BuilderInteractor features."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __all__ = [
     'FakeBuildQueue',
     'MockBuilderFactory',
@@ -20,13 +22,13 @@
     HasLength,
     MatchesDict,
     )
+from testtools.testcase import ExpectedException
 from testtools.twistedsupport import (
     assert_fails_with,
     AsynchronousDeferredRunTest,
     AsynchronousDeferredRunTestForBrokenTwisted,
     SynchronousDeferredRunTest,
     )
-from testtools.testcase import ExpectedException
 from twisted.internet import (
     defer,
     reactor as default_reactor,

=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
--- lib/lp/buildmaster/tests/test_manager.py	2017-12-19 17:22:44 +0000
+++ lib/lp/buildmaster/tests/test_manager.py	2018-06-06 11:29:12 +0000
@@ -2,11 +2,13 @@
 # NOTE: The first line above must stay first; do not move the copyright
 # notice to the top.  See http://www.python.org/dev/peps/pep-0263/.
 #
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the renovated slave scanner aka BuilddManager."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 import signal
 import time
@@ -902,7 +904,7 @@
         with ExpectedException(
                 BuildDaemonIsolationError,
                 "Allegedly clean slave not idle "
-                "\('BuilderStatus.BUILDING' instead\)"):
+                "\(u'BuilderStatus.BUILDING' instead\)"):
             yield scanner.scan()
         self.assertEqual(['status'], slave.call_log)
 
@@ -1057,7 +1059,7 @@
         slave = LostBuildingBrokenSlave()
         self.builder.current_build.cancel()
         with ExpectedException(
-                xmlrpclib.Fault, "<Fault 8002: 'Could not abort'>"):
+                xmlrpclib.Fault, "<Fault 8002: u'Could not abort'>"):
             yield self._getScanner().checkCancellation(self.vitals, slave)
 
 

=== modified file 'lib/lp/buildmaster/tests/test_packagebuild.py'
--- lib/lp/buildmaster/tests/test_packagebuild.py	2018-01-02 10:54:31 +0000
+++ lib/lp/buildmaster/tests/test_packagebuild.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for `IPackageBuild`."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import hashlib

=== modified file 'lib/lp/buildmaster/tests/test_processor.py'
--- lib/lp/buildmaster/tests/test_processor.py	2018-01-02 16:10:26 +0000
+++ lib/lp/buildmaster/tests/test_processor.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test Processor features."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from zope.component import getUtility
 
 from lp.buildmaster.interfaces.processor import (

=== modified file 'lib/lp/buildmaster/tests/test_queuedepth.py'
--- lib/lp/buildmaster/tests/test_queuedepth.py	2018-01-02 16:10:26 +0000
+++ lib/lp/buildmaster/tests/test_queuedepth.py	2018-06-06 11:29:12 +0000
@@ -1,7 +1,9 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 """Test BuildQueue start time estimation."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from datetime import (
     datetime,
     timedelta,

=== modified file 'lib/lp/buildmaster/tests/test_webservice.py'
--- lib/lp/buildmaster/tests/test_webservice.py	2018-01-31 00:13:47 +0000
+++ lib/lp/buildmaster/tests/test_webservice.py	2018-06-06 11:29:12 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the builders webservice ."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from json import dumps


Follow ups