launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00150
[Merge] lp:~jtv/launchpad/test-cruft-archivepublisher into lp:launchpad/devel
Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/test-cruft-archivepublisher into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
Removes test boilerplate that we no longer need from archivepublisher, and fixes lint in affected tests.
--
https://code.launchpad.net/~jtv/launchpad/test-cruft-archivepublisher/+merge/30198
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/test-cruft-archivepublisher into lp:launchpad/devel.
=== modified file 'lib/lp/archivepublisher/tests/test_config.py'
--- lib/lp/archivepublisher/tests/test_config.py 2009-06-24 23:28:16 +0000
+++ lib/lp/archivepublisher/tests/test_config.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for Config.py"""
@@ -46,7 +46,7 @@
from lp.archivepublisher.config import Config
d = Config(self.ubuntutest)
archs = d.archTagsForSeries("hoary-test")
- self.assertEquals( len(archs), 2)
+ self.assertEquals(len(archs), 2)
def testDistroConfig(self):
"""Config should have parsed a distro config"""
@@ -54,7 +54,3 @@
d = Config(self.ubuntutest)
# NOTE: Add checks here when you add stuff in util.py
self.assertEquals(d.stayofexecution, 5)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/archivepublisher/tests/test_customupload.py'
--- lib/lp/archivepublisher/tests/test_customupload.py 2010-03-10 00:13:27 +0000
+++ lib/lp/archivepublisher/tests/test_customupload.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for `CustomUploads`."""
@@ -177,7 +177,7 @@
def test_extract(self):
"""Test that the extract method calls the verify function.
-
+
This test is different from the previous tests in that it actually
pokes a fake tar file on disk. This is slower, so it's only done
once, here.
@@ -196,7 +196,3 @@
self.custom_processor.extract)
finally:
shutil.rmtree(self.tarfile_path)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/archivepublisher/tests/test_deathrow.py'
--- lib/lp/archivepublisher/tests/test_deathrow.py 2010-02-09 12:32:01 +0000
+++ lib/lp/archivepublisher/tests/test_deathrow.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for deathrow class."""
@@ -9,7 +9,6 @@
import os
import shutil
import tempfile
-import unittest
from zope.component import getUtility
@@ -43,6 +42,7 @@
"""
pool_path = tempfile.mkdtemp('-pool')
temp_path = tempfile.mkdtemp('-pool-tmp')
+
def clean_pool(pool_path, temp_path):
shutil.rmtree(pool_path)
shutil.rmtree(temp_path)
@@ -57,8 +57,7 @@
return diskpool.pathFor(
pub_file.componentname.encode('utf-8'),
pub_file.sourcepackagename.encode('utf8'),
- pub_file.libraryfilealiasfilename.encode('utf-8')
- )
+ pub_file.libraryfilealiasfilename.encode('utf-8'))
def assertIsFile(self, path):
"""Assert the path exists and is a regular file."""
@@ -145,8 +144,3 @@
self.assertDoesNotExist(main_dsc_path)
self.assertDoesNotExist(universe_dsc_path)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
-
=== modified file 'lib/lp/archivepublisher/tests/test_debversion.py'
--- lib/lp/archivepublisher/tests/test_debversion.py 2010-02-12 18:30:30 +0000
+++ lib/lp/archivepublisher/tests/test_debversion.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for debversion."""
@@ -9,6 +9,7 @@
import unittest
+
class Version(unittest.TestCase):
# Known values that should work
VALUES = (
@@ -25,27 +26,27 @@
# Known less-than comparisons
COMPARISONS = (
- ( "1.0", "1.1" ),
- ( "1.1", "2.0" ),
- ( "2.1", "2.10" ),
- ( "2.2", "2.10" ),
- ( "1.0", "1:1.0" ),
- ( "1:9.0", "2:1.0" ),
- ( "1.0-1", "1.0-2" ),
- ( "1.0", "1.0-1" ),
- ( "1a", "1b" ),
- ( "1a", "2" ),
- ( "1a", "1." ),
- ( "1a", "1+" ),
- ( "1:1a", "1:1:" ),
- ( "1a-1", "1--1" ) ,
- ( "1+-1", "1--1" ),
- ( "1--1", "1.-1" ),
- ( "1:1.", "1:1:" ),
- ( "1A", "1a" ),
- ( "1~", "1" ),
- ( "1~", "1~a" ),
- ( "1~a", "1~b" ),
+ ("1.0", "1.1"),
+ ("1.1", "2.0"),
+ ("2.1", "2.10"),
+ ("2.2", "2.10"),
+ ("1.0", "1:1.0"),
+ ("1:9.0", "2:1.0"),
+ ("1.0-1", "1.0-2"),
+ ("1.0", "1.0-1"),
+ ("1a", "1b"),
+ ("1a", "2"),
+ ("1a", "1."),
+ ("1a", "1+"),
+ ("1:1a", "1:1:"),
+ ("1a-1", "1--1"),
+ ("1+-1", "1--1"),
+ ("1--1", "1.-1"),
+ ("1:1.", "1:1:"),
+ ("1A", "1a"),
+ ("1~", "1"),
+ ("1~", "1~a"),
+ ("1~a", "1~b"),
)
def testAcceptsString(self):
@@ -167,35 +168,36 @@
class Strcut(unittest.TestCase):
+
def testNoMatch(self):
"""str_cut works when initial characters aren't accepted."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("foo", 0, "gh"), ( "", 0 ))
+ self.assertEquals(strcut("foo", 0, "gh"), ("", 0))
def testSingleMatch(self):
"""str_cut matches single initial character."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("foo", 0, "fgh"), ( "f", 1 ))
+ self.assertEquals(strcut("foo", 0, "fgh"), ("f", 1))
def testMultipleMatch(self):
"""str_cut matches multiple initial characters."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("foobar", 0, "fo"), ( "foo", 3 ))
+ self.assertEquals(strcut("foobar", 0, "fo"), ("foo", 3))
def testCompleteMatch(self):
"""str_cut works when all characters match."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("foo", 0, "fo"), ( "foo", 3 ))
+ self.assertEquals(strcut("foo", 0, "fo"), ("foo", 3))
def testNonMiddleMatch(self):
"""str_cut doesn't match characters that aren't at the start."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("barfooquux", 0, "fo"), ( "", 0 ))
+ self.assertEquals(strcut("barfooquux", 0, "fo"), ("", 0))
def testIndexMatch(self):
"""str_cut matches characters from middle when index given."""
from lp.archivepublisher.debversion import strcut
- self.assertEquals(strcut("barfooquux", 3, "fo"), ( "foo", 6 ))
+ self.assertEquals(strcut("barfooquux", 3, "fo"), ("foo", 6))
class DebOrder(unittest.TestCase):
@@ -242,7 +244,7 @@
"foo+bar",
"foo-bar",
"foo.bar",
- "foo:bar"
+ "foo:bar",
)
# Non-letter characters in order
@@ -339,6 +341,7 @@
class DebCmp(unittest.TestCase):
+
def testEmptyString(self):
"""deb_cmp returns 0 for the empty string."""
from lp.archivepublisher.debversion import deb_cmp
@@ -368,7 +371,3 @@
"""deb_cmp works when string potion is empty."""
from lp.archivepublisher.debversion import deb_cmp
self.assertEquals(deb_cmp("100", "foo100"), -1)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/archivepublisher/tests/test_dominator.py'
--- lib/lp/archivepublisher/tests/test_dominator.py 2010-01-31 19:36:27 +0000
+++ lib/lp/archivepublisher/tests/test_dominator.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for domination.py."""
@@ -7,7 +7,6 @@
import datetime
import pytz
-import unittest
from zope.component import getUtility
@@ -80,13 +79,13 @@
flush_database_updates()
# The dominant version remains correctly published.
- dominant = self.checkSourcePublication(
+ dominant = self.checkSourcePublication(
dominant_source, PackagePublishingStatus.PUBLISHED)
self.assertTrue(dominant.supersededby is None)
self.assertTrue(dominant.datesuperseded is None)
# The dominated version is correctly dominated.
- dominated = self.checkSourcePublication(
+ dominated = self.checkSourcePublication(
dominated_source, PackagePublishingStatus.SUPERSEDED)
self.assertEqual(
dominated.supersededby, dominant.sourcepackagerelease)
@@ -113,13 +112,13 @@
flush_database_updates()
# Dominant version remains correctly published.
- dominant = self.checkBinaryPublication(
+ dominant = self.checkBinaryPublication(
dominant, PackagePublishingStatus.PUBLISHED)
self.assertTrue(dominant.supersededby is None)
self.assertTrue(dominant.datesuperseded is None)
# Dominated version is correctly dominated.
- dominated = self.checkBinaryPublication(
+ dominated = self.checkBinaryPublication(
dominated, PackagePublishingStatus.SUPERSEDED)
self.assertEqual(
dominated.supersededby, dominant.binarypackagerelease.build)
@@ -142,7 +141,7 @@
dominator._dominateBinary(dominated, dominant)
flush_database_updates()
- dominated = self.checkBinaryPublication(
+ dominated = self.checkBinaryPublication(
dominated, PackagePublishingStatus.SUPERSEDED)
self.assertEqual(
dominated.supersededby, dominant.binarypackagerelease.build)
@@ -180,7 +179,7 @@
AssertionError, dominator._dominateBinary, dominated, dominant)
# The refused publishing record remains the same.
- dominated = self.checkBinaryPublication(
+ dominated = self.checkBinaryPublication(
dominated, PackagePublishingStatus.SUPERSEDED)
self.assertEqual(dominated.datesuperseded, manual_domination_date)
@@ -191,7 +190,7 @@
dominator._dominateBinary(dominated, dominant)
flush_database_updates()
- dominated = self.checkBinaryPublication(
+ dominated = self.checkBinaryPublication(
dominated, PackagePublishingStatus.SUPERSEDED)
self.assertEqual(dominated.datesuperseded, manual_domination_date)
@@ -394,6 +393,7 @@
superseded_source.scheduleddeletiondate,
lag=datetime.timedelta(days=publisher._config.stayofexecution))
+
class TestDominationOfObsoletedSeries(TestDomination):
"""Replay domination tests upon a OBSOLETED distroseries."""
@@ -401,8 +401,3 @@
TestDomination.setUp(self)
self.ubuntutest['breezy-autotest'].status = (
SeriesStatus.OBSOLETE)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
-
=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
--- lib/lp/archivepublisher/tests/test_ftparchive.py 2010-04-15 02:09:00 +0000
+++ lib/lp/archivepublisher/tests/test_ftparchive.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for ftparchive.py"""
@@ -30,10 +30,11 @@
# apt-ftparchive Sources file content, such that the output of lucid
# apt-ftparchive is the same as on karmic.
return re.subn(r'(?sm)^Checksums-.*?(?=^[^ ])', '', text)[0]
-
+
class SamplePublisher:
"""Publisher emulation test class."""
+
def __init__(self, archive):
self.archive = archive
@@ -155,7 +156,7 @@
hoary, PackagePublishingPocket.RELEASE)
expectedBinaries = [
('pmount', 'hoary', 'main', 'base', 'extra'),
- ('pmount', 'hoary', 'universe', 'editors', 'important')
+ ('pmount', 'hoary', 'universe', 'editors', 'important'),
]
self.assertEqual(expectedBinaries, list(published_binaries))
@@ -220,9 +221,13 @@
binary_files = fa.getBinaryFiles(
hoary, PackagePublishingPocket.RELEASE)
- expected_files = [
- ('pmount', 'hoary', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa')
- ]
+ expected_files = [(
+ 'pmount',
+ 'hoary',
+ 'pmount_1.9-1_all.deb',
+ 'main',
+ 'binary-hppa',
+ )]
self.assertEqual(expected_files, list(binary_files))
def test_publishFileLists(self):
@@ -230,7 +235,7 @@
fa = self._setUpFTPArchiveHandler()
source_files = FakeSelectResult(
- [('foo', 'hoary-test', 'foo.dsc', 'main')])
+ [('foo', 'hoary-test', 'foo.dsc', 'main')])
binary_files = FakeSelectResult(
[('foo', 'hoary-test', 'foo.deb', 'main', 'binary-i386')])
fa.publishFileLists(source_files, binary_files)
@@ -252,14 +257,14 @@
# Calculate overrides.
source_overrides = FakeSelectResult(
- [('foo', 'hoary-test', 'main', 'misc'),])
+ [('foo', 'hoary-test', 'main', 'misc'), ])
binary_overrides = FakeSelectResult(
[('foo', 'hoary-test', 'main', 'misc', 'extra')])
fa.publishOverrides(source_overrides, binary_overrides)
# Calculate filelists.
source_files = FakeSelectResult(
- [('foo', 'hoary-test', 'foo.dsc', 'main')])
+ [('foo', 'hoary-test', 'foo.dsc', 'main')])
binary_files = FakeSelectResult(
[('foo', 'hoary-test', 'foo.deb', 'main', 'binary-i386')])
fa.publishFileLists(source_files, binary_files)
@@ -376,8 +381,3 @@
f.close()
self.assertEqual("", contents)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
-
=== modified file 'lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py'
--- lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py 2010-04-19 15:05:27 +0000
+++ lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test the generate_ppa_htaccess.py script. """
@@ -10,7 +10,6 @@
import subprocess
import sys
import tempfile
-import unittest
from zope.component import getUtility
@@ -127,7 +126,7 @@
expected_contents = [
"user:XXq2wKiyI43A2",
- "user2:XXaQB8b5Gtwi."
+ "user2:XXaQB8b5Gtwi.",
]
file = open(filename, "r")
@@ -568,7 +567,3 @@
"feedback@xxxxxxxxxxxxx\n\n"
"Regards,\n"
"The Launchpad team")
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/archivepublisher/tests/test_pool.py'
--- lib/lp/archivepublisher/tests/test_pool.py 2010-02-09 00:17:40 +0000
+++ lib/lp/archivepublisher/tests/test_pool.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for pool.py."""
@@ -7,7 +7,6 @@
import hashlib
import os
-import sys
import shutil
import unittest
@@ -18,6 +17,7 @@
class MockFile:
+
def __init__(self, contents):
self.contents = contents
@@ -35,6 +35,7 @@
class PoolTestingFile:
+
def __init__(self, pool, sourcename, filename):
self.pool = pool
self.sourcename = sourcename
@@ -66,15 +67,16 @@
def testPoolificationOkay(self):
"""poolify should poolify properly"""
cases = (
- ( "foo", "main", "main/f/foo" ),
- ( "foo", "universe", "universe/f/foo" ),
- ( "libfoo", "main", "main/libf/libfoo" )
+ ("foo", "main", "main/f/foo"),
+ ("foo", "universe", "universe/f/foo"),
+ ("libfoo", "main", "main/libf/libfoo"),
)
for case in cases:
- self.assertEqual( case[2], poolify(case[0], case[1]) )
+ self.assertEqual(case[2], poolify(case[0], case[1]))
class TestPool(unittest.TestCase):
+
def setUp(self):
self.pool_path = mkdtemp()
self.temp_path = mkdtemp()
@@ -137,7 +139,3 @@
foo.removeFromPool("main")
self.assertFalse(foo.checkExists("main"))
self.assertTrue(foo.checkIsFile("universe"))
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2010-07-07 06:51:43 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for publisher class."""
@@ -13,7 +13,6 @@
import stat
import tempfile
import transaction
-import unittest
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
@@ -370,7 +369,7 @@
foo_path = "%s/main/f/foo/foo_1.dsc" % test_pool_dir
self.assertEqual(
open(foo_path).read().strip(),
- 'I am supposed to be a embargoed archive',)
+ 'I am supposed to be a embargoed archive', )
# remove locally created dir
shutil.rmtree(test_pool_dir)
@@ -472,7 +471,6 @@
self.assertEqual(
1 + old_num_pending_archives, new_num_pending_archives)
-
def _checkCompressedFile(self, archive_publisher, compressed_file_path,
uncompressed_file_path):
"""Assert that a compressed file is equal to its uncompressed version.
@@ -503,7 +501,7 @@
raise AssertionError(
'Unsupported compression: %s' % compressed_file_path)
- index_file = open(index_path,'r')
+ index_file = open(index_path, 'r')
index_contents = index_file.read().splitlines()
index_file.close()
@@ -696,7 +694,7 @@
expected_dirty_pockets = [
('breezy-autotest', PackagePublishingPocket.RELEASE),
('breezy-autotest', PackagePublishingPocket.SECURITY),
- ('breezy-autotest', PackagePublishingPocket.BACKPORTS)
+ ('breezy-autotest', PackagePublishingPocket.BACKPORTS),
]
self.checkDirtyPockets(publisher, expected=expected_dirty_pockets)
@@ -710,7 +708,7 @@
expected_dirty_pockets = [
('breezy-autotest', PackagePublishingPocket.SECURITY),
- ('breezy-autotest', PackagePublishingPocket.BACKPORTS)
+ ('breezy-autotest', PackagePublishingPocket.BACKPORTS),
]
self.checkDirtyPockets(publisher, expected=expected_dirty_pockets)
@@ -1072,7 +1070,7 @@
self.assertEqual(
self._getReleaseFileOrigin(arch_release_contents),
'Canonical')
-
+
# The Label: field should be set to the archive displayname
self.assertEqual(release_contents[1], 'Label: Partner archive')
@@ -1124,7 +1122,6 @@
self.archive_publisher = getPublisher(
archive, allowed_suites, self.logger)
-
def _publishArchive(self, archive):
"""Publish a test source in the given archive.
@@ -1205,8 +1202,3 @@
# All done, turn test-keyserver off.
z.tearDown()
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
-
=== modified file 'lib/lp/archivepublisher/tests/test_repositoryindexfile.py'
--- lib/lp/archivepublisher/tests/test_repositoryindexfile.py 2009-06-24 23:28:16 +0000
+++ lib/lp/archivepublisher/tests/test_repositoryindexfile.py 2010-07-18 00:37:42 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for `RepositoryIndexFile`."""
@@ -132,7 +132,3 @@
self.assertRaises(
AssertionError,
RepositoryIndexFile, self.root, missing_temp_root, 'boing')
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)