launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22063
[Merge] lp:~cjwatson/launchpad/modern-testtools-cleanup into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/modern-testtools-cleanup into lp:launchpad with lp:~cjwatson/launchpad/upgrade-testtools as a prerequisite.
Commit message:
Take advantage of modern testtools/fixtures to simplify a few things.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/modern-testtools-cleanup/+merge/335396
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/modern-testtools-cleanup into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/tests/test_archivesigningkey.py'
--- lib/lp/archivepublisher/tests/test_archivesigningkey.py 2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_archivesigningkey.py 2017-12-19 17:34:35 +0000
@@ -7,7 +7,7 @@
import os
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from zope.component import getUtility
=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
--- lib/lp/archivepublisher/tests/test_publishdistro.py 2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_publishdistro.py 2017-12-19 17:34:35 +0000
@@ -11,11 +11,11 @@
import subprocess
import sys
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
Not,
PathExists,
)
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2017-12-19 17:34:35 +0000
@@ -32,7 +32,6 @@
except ImportError:
from backports import lzma
import pytz
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
ContainsAll,
DirContains,
@@ -49,6 +48,7 @@
PathExists,
SamePath,
)
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from zope.component import getUtility
=== modified file 'lib/lp/archivepublisher/tests/test_signing.py'
--- lib/lp/archivepublisher/tests/test_signing.py 2017-08-02 19:13:48 +0000
+++ lib/lp/archivepublisher/tests/test_signing.py 2017-12-19 17:34:35 +0000
@@ -10,7 +10,6 @@
import tarfile
from fixtures import MonkeyPatch
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
Contains,
Matcher,
@@ -18,6 +17,7 @@
Mismatch,
Not,
)
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from zope.component import getUtility
=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py'
--- lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2016-06-01 15:13:12 +0000
+++ lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2017-12-19 17:34:35 +0000
@@ -12,7 +12,7 @@
import tempfile
from testtools import ExpectedException
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
=== modified file 'lib/lp/buildmaster/tests/test_interactor.py'
--- lib/lp/buildmaster/tests/test_interactor.py 2017-09-13 08:05:35 +0000
+++ lib/lp/buildmaster/tests/test_interactor.py 2017-12-19 17:34:35 +0000
@@ -15,17 +15,17 @@
from lpbuildd.slave import BuilderStatus
from lpbuildd.tests.harness import BuilddSlaveTestSetup
-from testtools.deferredruntest import (
+from testtools.matchers import (
+ ContainsAll,
+ HasLength,
+ MatchesDict,
+ )
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
AsynchronousDeferredRunTestForBrokenTwisted,
SynchronousDeferredRunTest,
)
-from testtools.matchers import (
- ContainsAll,
- HasLength,
- MatchesDict,
- )
from testtools.testcase import ExpectedException
from twisted.internet import (
defer,
=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
--- lib/lp/buildmaster/tests/test_manager.py 2017-04-03 12:35:03 +0000
+++ lib/lp/buildmaster/tests/test_manager.py 2017-12-19 17:34:35 +0000
@@ -12,12 +12,12 @@
import time
import xmlrpclib
-from testtools.deferredruntest import (
+from testtools.matchers import Equals
+from testtools.testcase import ExpectedException
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
)
-from testtools.matchers import Equals
-from testtools.testcase import ExpectedException
import transaction
from twisted.internet import (
defer,
=== modified file 'lib/lp/code/model/tests/test_recipebuilder.py'
--- lib/lp/code/model/tests/test_recipebuilder.py 2017-10-04 01:53:48 +0000
+++ lib/lp/code/model/tests/test_recipebuilder.py 2017-12-19 17:34:35 +0000
@@ -11,8 +11,8 @@
import shutil
import tempfile
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import MatchesListwise
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from twisted.trial.unittest import TestCase as TrialTestCase
=== modified file 'lib/lp/codehosting/codeimport/tests/test_workermonitor.py'
--- lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2017-09-02 13:29:14 +0000
+++ lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2017-12-19 17:34:35 +0000
@@ -19,7 +19,7 @@
from bzrlib.tests import TestCaseInTempDir
from dulwich.repo import Repo as GitRepo
import oops_twisted
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
flush_logged_errors,
=== modified file 'lib/lp/codehosting/puller/tests/test_acceptance.py'
--- lib/lp/codehosting/puller/tests/test_acceptance.py 2012-09-18 19:41:02 +0000
+++ lib/lp/codehosting/puller/tests/test_acceptance.py 2017-12-19 17:34:35 +0000
@@ -128,8 +128,7 @@
output and error are strings contain the output of the process to
stdout and stderr respectively.
"""
- tempdir = self.useFixture(TempDir()).path
- logfile = os.path.join(tempdir, "supermirror_test.log")
+ logfile = self.useFixture(TempDir()).join("supermirror_test.log")
command = [
'%s/bin/py' % config.root, self._puller_script, '--log-file',
logfile, '-q'] + list(args)
=== modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py'
--- lib/lp/codehosting/puller/tests/test_scheduler.py 2012-10-31 00:54:33 +0000
+++ lib/lp/codehosting/puller/tests/test_scheduler.py 2017-12-19 17:34:35 +0000
@@ -13,7 +13,7 @@
format_registry,
)
from bzrlib.urlutils import join as urljoin
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
flush_logged_errors,
=== modified file 'lib/lp/codehosting/tests/helpers.py'
--- lib/lp/codehosting/tests/helpers.py 2017-01-12 18:02:15 +0000
+++ lib/lp/codehosting/tests/helpers.py 2017-12-19 17:34:35 +0000
@@ -22,7 +22,7 @@
TestNotApplicable,
TestSkipped,
)
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from lp.code.enums import BranchType
from lp.codehosting.vfs import branch_id_to_path
=== modified file 'lib/lp/codehosting/tests/test_sftp.py'
--- lib/lp/codehosting/tests/test_sftp.py 2016-02-05 16:51:12 +0000
+++ lib/lp/codehosting/tests/test_sftp.py 2017-12-19 17:34:35 +0000
@@ -14,7 +14,7 @@
from bzrlib.transport import get_transport
from bzrlib.transport.memory import MemoryTransport
from lazr.sshserver.sftp import FileIsADirectory
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
)
=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfs.py'
--- lib/lp/codehosting/vfs/tests/test_branchfs.py 2017-12-19 17:34:35 +0000
+++ lib/lp/codehosting/vfs/tests/test_branchfs.py 2017-12-19 17:34:35 +0000
@@ -38,7 +38,7 @@
escape,
local_path_to_url,
)
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
)
=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfsclient.py'
--- lib/lp/codehosting/vfs/tests/test_branchfsclient.py 2015-10-19 10:56:16 +0000
+++ lib/lp/codehosting/vfs/tests/test_branchfsclient.py 2017-12-19 17:34:35 +0000
@@ -5,7 +5,7 @@
__metaclass__ = type
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from lp.code.interfaces.codehosting import BRANCH_TRANSPORT
from lp.codehosting.inmemory import (
=== modified file 'lib/lp/registry/tests/test_teammembership.py'
--- lib/lp/registry/tests/test_teammembership.py 2016-01-26 15:47:37 +0000
+++ lib/lp/registry/tests/test_teammembership.py 2017-12-19 17:34:35 +0000
@@ -8,7 +8,6 @@
datetime,
timedelta,
)
-import os
import pickle
import re
import subprocess
@@ -1292,9 +1291,9 @@
logger = BufferLogger()
self.addDetail("log", logger.content)
info = fetch_team_participation_info(logger)
- tempdir = self.useFixture(TempDir()).path
- filename_in = os.path.join(tempdir, "info.in")
- filename_out = os.path.join(tempdir, "info.out")
+ tempdir = self.useFixture(TempDir())
+ filename_in = tempdir.join("info.in")
+ filename_out = tempdir.join("info.out")
fout = bz2.BZ2File(filename_in, "w")
try:
pickle.dump(info, fout, pickle.HIGHEST_PROTOCOL)
=== modified file 'lib/lp/services/apachelogparser/tests/test_apachelogparser.py'
--- lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2017-10-05 19:01:06 +0000
+++ lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2017-12-19 17:34:35 +0000
@@ -391,8 +391,8 @@
def test_sorts_by_mtime(self):
# Files are sorted by ascending mtime.
- root = self.useFixture(TempDir()).path
- file_paths = [os.path.join(root, str(name)) for name in range(3)]
+ root = self.useFixture(TempDir())
+ file_paths = [root.join(str(name)) for name in range(3)]
now = time.time()
for i, path in enumerate(file_paths):
write_file(path, '%s\n' % i)
=== modified file 'lib/lp/services/config/tests/test_config.py'
--- lib/lp/services/config/tests/test_config.py 2016-10-03 23:48:34 +0000
+++ lib/lp/services/config/tests/test_config.py 2017-12-19 17:34:35 +0000
@@ -95,20 +95,19 @@
# The launchpad.config_overlay_dir setting can be used to load
# extra config files over the top. This is useful for overlaying
# non-version-controlled secrets.
- config_dir = self.useFixture(TempDir(rootdir='configs')).path
- config_name = os.path.basename(config_dir)
- overlay_dir = self.useFixture(TempDir(rootdir='configs')).path
- with open(os.path.join(config_dir, 'launchpad-lazr.conf'), 'w') as f:
+ config_dir = self.useFixture(TempDir(rootdir='configs'))
+ config_name = os.path.basename(config_dir.path)
+ overlay_dir = self.useFixture(TempDir(rootdir='configs'))
+ with open(config_dir.join('launchpad-lazr.conf'), 'w') as f:
f.write("""
[meta]
extends: ../testrunner/launchpad-lazr.conf
[launchpad]
config_overlay_dir: ../%s
- """ % os.path.basename(overlay_dir))
+ """ % os.path.basename(overlay_dir.path))
os.symlink(
- '../testrunner/launchpad.conf',
- os.path.join(config_dir, 'launchpad.conf'))
+ '../testrunner/launchpad.conf', config_dir.join('launchpad.conf'))
config = lp.services.config.config
@@ -116,7 +115,7 @@
self.assertEqual('launchpad_main', config.launchpad.dbuser)
self.assertEqual('', config.launchpad.site_message)
- with open(os.path.join(overlay_dir, '00-test-lazr.conf'), 'w') as f:
+ with open(overlay_dir.join('00-test-lazr.conf'), 'w') as f:
f.write("""
[launchpad]
dbuser: overlay-user
@@ -126,7 +125,7 @@
self.assertEqual('overlay-user', config.launchpad.dbuser)
self.assertEqual('An overlay!', config.launchpad.site_message)
- with open(os.path.join(overlay_dir, '01-test-lazr.conf'), 'w') as f:
+ with open(overlay_dir.join('01-test-lazr.conf'), 'w') as f:
f.write("""
[launchpad]
site_message: Another overlay!
@@ -135,7 +134,7 @@
self.assertEqual('overlay-user', config.launchpad.dbuser)
self.assertEqual('Another overlay!', config.launchpad.site_message)
- os.unlink(os.path.join(overlay_dir, '00-test-lazr.conf'))
+ os.unlink(overlay_dir.join('00-test-lazr.conf'))
with ConfigUseFixture(config_name):
self.assertEqual('launchpad_main', config.launchpad.dbuser)
self.assertEqual('Another overlay!', config.launchpad.site_message)
=== modified file 'lib/lp/services/log/logger.py'
--- lib/lp/services/log/logger.py 2017-10-05 12:46:52 +0000
+++ lib/lp/services/log/logger.py 2017-12-19 17:34:35 +0000
@@ -219,10 +219,6 @@
Use with `testtools.TestCase.addDetail`, `fixtures.Fixture.addDetail`,
and anything else that understands details.
"""
- # Only import these here to avoid importing testtools outside tests.
- from testtools.content import (
- Content,
- UTF8_TEXT,
- )
- get_bytes = lambda: [self.getLogBuffer().encode("utf-8")]
- return Content(UTF8_TEXT, get_bytes)
+ # Only import this here to avoid importing testtools outside tests.
+ from testtools.content import text_content
+ return text_content(self.getLogBuffer())
=== modified file 'lib/lp/services/tests/test_utils.py'
--- lib/lp/services/tests/test_utils.py 2014-08-29 01:34:04 +0000
+++ lib/lp/services/tests/test_utils.py 2017-12-19 17:34:35 +0000
@@ -340,8 +340,7 @@
def test_save_and_load(self):
data = {1: 2, "room": 101}
- tempdir = self.useFixture(TempDir()).path
- tempfile = os.path.join(tempdir, "dump")
+ tempfile = self.useFixture(TempDir()).join("dump")
save_bz2_pickle(data, tempfile)
self.assertEqual(data, load_bz2_pickle(tempfile))
=== modified file 'lib/lp/services/twistedsupport/tests/test_processmonitor.py'
--- lib/lp/services/twistedsupport/tests/test_processmonitor.py 2015-10-14 15:22:01 +0000
+++ lib/lp/services/twistedsupport/tests/test_processmonitor.py 2017-12-19 17:34:35 +0000
@@ -5,7 +5,7 @@
__metaclass__ = type
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
flush_logged_errors,
=== modified file 'lib/lp/services/twistedsupport/tests/test_twistedsupport.py'
--- lib/lp/services/twistedsupport/tests/test_twistedsupport.py 2015-10-14 15:22:01 +0000
+++ lib/lp/services/twistedsupport/tests/test_twistedsupport.py 2017-12-19 17:34:35 +0000
@@ -5,7 +5,7 @@
__metaclass__ = type
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
assert_fails_with,
AsynchronousDeferredRunTest,
)
=== modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py'
--- lib/lp/snappy/tests/test_snapbuildbehaviour.py 2017-10-20 13:35:42 +0000
+++ lib/lp/snappy/tests/test_snapbuildbehaviour.py 2017-12-19 17:34:35 +0000
@@ -18,7 +18,6 @@
from mock import patch
from pymacaroons import Macaroon
from testtools import ExpectedException
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
AfterPreprocessing,
Equals,
@@ -27,6 +26,7 @@
MatchesListwise,
StartsWith,
)
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from twisted.trial.unittest import TestCase as TrialTestCase
=== modified file 'lib/lp/soyuz/adapters/tests/test_archivedependencies.py'
--- lib/lp/soyuz/adapters/tests/test_archivedependencies.py 2017-06-14 02:44:33 +0000
+++ lib/lp/soyuz/adapters/tests/test_archivedependencies.py 2017-12-19 17:34:35 +0000
@@ -9,11 +9,11 @@
import os.path
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
MatchesSetwise,
StartsWith,
)
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from twisted.internet.threads import deferToThread
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2017-12-19 17:34:35 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2017-12-19 17:34:35 +0000
@@ -12,7 +12,6 @@
import os.path
from pytz import UTC
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
AllMatch,
DocTestMatches,
@@ -23,6 +22,7 @@
MatchesStructure,
)
from testtools.testcase import ExpectedException
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from zope.component import getUtility
=== modified file 'lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py'
--- lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py 2017-07-26 13:21:25 +0000
+++ lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py 2017-12-19 17:34:35 +0000
@@ -11,8 +11,8 @@
import tempfile
from storm.store import Store
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import MatchesListwise
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from twisted.trial.unittest import TestCase as TrialTestCase
=== modified file 'lib/lp/soyuz/tests/test_livefsbuildbehaviour.py'
--- lib/lp/soyuz/tests/test_livefsbuildbehaviour.py 2017-04-29 23:51:28 +0000
+++ lib/lp/soyuz/tests/test_livefsbuildbehaviour.py 2017-12-19 17:34:35 +0000
@@ -10,8 +10,8 @@
import fixtures
import pytz
-from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import MatchesListwise
+from testtools.twistedsupport import AsynchronousDeferredRunTest
import transaction
from twisted.internet import defer
from twisted.trial.unittest import TestCase as TrialTestCase
=== modified file 'lib/lp/testing/keyserver/tests/test_inprocess.py'
--- lib/lp/testing/keyserver/tests/test_inprocess.py 2017-04-29 15:24:32 +0000
+++ lib/lp/testing/keyserver/tests/test_inprocess.py 2017-12-19 17:34:35 +0000
@@ -7,7 +7,7 @@
__metaclass__ = type
-from testtools.deferredruntest import (
+from testtools.twistedsupport import (
AsynchronousDeferredRunTestForBrokenTwisted,
)
from twisted.internet import defer
=== modified file 'lib/lp/testing/keyserver/tests/test_web.py'
--- lib/lp/testing/keyserver/tests/test_web.py 2015-06-24 00:17:11 +0000
+++ lib/lp/testing/keyserver/tests/test_web.py 2017-12-19 17:34:35 +0000
@@ -8,7 +8,7 @@
import os
import shutil
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet.endpoints import serverFromString
from twisted.python.failure import Failure
from twisted.web.client import getPage
=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildbehaviour.py'
--- lib/lp/translations/tests/test_translationtemplatesbuildbehaviour.py 2017-11-08 10:57:11 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuildbehaviour.py 2017-12-19 17:34:35 +0000
@@ -8,7 +8,7 @@
import os
import pytz
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from zope.component import getUtility
Follow ups