Merge lp:~jml/launchpad/upcall-testcase into lp:launchpad
- upcall-testcase
- Merge into devel
Proposed by
Jonathan Lange
on 2010-01-08
| Status: | Merged |
|---|---|
| Approved by: | Michael Hudson-Doyle on 2010-01-08 |
| Approved revision: | not available |
| Merged at revision: | not available |
| Proposed branch: | lp:~jml/launchpad/upcall-testcase |
| Merge into: | lp:launchpad |
| Diff against target: |
828 lines (+88/-47) 28 files modified
lib/canonical/config/tests/test_config_lookup.py (+7/-7) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py (+17/-12) lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py (+3/-0) lib/canonical/launchpad/scripts/tests/test_runlaunchpad.py (+2/-2) lib/canonical/launchpad/webapp/tests/__init__.py (+2/-1) lib/canonical/launchpad/webapp/tests/test_dbpolicy.py (+8/-5) lib/canonical/launchpad/webapp/tests/test_menu.py (+1/-0) lib/canonical/launchpad/webapp/tests/test_servers.py (+1/-2) lib/lp/archiveuploader/tests/test_buildduploads.py (+2/-2) lib/lp/archiveuploader/tests/test_ppauploadprocessor.py (+1/-1) lib/lp/archiveuploader/tests/test_securityuploads.py (+2/-2) lib/lp/archiveuploader/tests/test_uploadprocessor.py (+2/-1) lib/lp/code/browser/tests/test_branch.py (+4/-2) lib/lp/code/mail/tests/test_codehandler.py (+9/-3) lib/lp/code/model/tests/test_branch.py (+4/-1) lib/lp/code/model/tests/test_codereviewkarma.py (+2/-1) lib/lp/code/model/tests/test_revisionauthor.py (+3/-0) lib/lp/codehosting/puller/tests/test_worker.py (+1/-0) lib/lp/codehosting/tests/test_rewrite.py (+1/-1) lib/lp/registry/tests/test_distroseries.py (+1/-0) lib/lp/registry/tests/test_prf_walker.py (+3/-0) lib/lp/scripts/utilities/tests/test_sanitizedb.py (+1/-0) lib/lp/services/apachelogparser/tests/test_apachelogparser.py (+2/-0) lib/lp/services/database/tests/test_prejoin.py (+1/-0) lib/lp/services/mail/tests/test_mailbox.py (+2/-4) lib/lp/services/memcache/tests/test_memcache_client.py (+1/-0) lib/lp/soyuz/scripts/tests/test_copypackage.py (+1/-0) lib/lp/translations/scripts/tests/test_remove_translations.py (+4/-0) |
| To merge this branch: | bzr merge lp:~jml/launchpad/upcall-testcase |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Hudson-Doyle | 2010-01-08 | Approve on 2010-01-08 | |
|
Review via email:
|
|||
Commit Message
Upcall setUp and tearDown everywhere, allowing use of testtools
Description of the Change
To post a comment you must log in.
| Jonathan Lange (jml) wrote : | # |
| Michael Hudson-Doyle (mwhudson) wrote : | # |
It looks fine. I worry slightly about doing super(.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'lib/canonical/config/tests/test_config_lookup.py' |
| 2 | --- lib/canonical/config/tests/test_config_lookup.py 2009-07-17 00:26:05 +0000 |
| 3 | +++ lib/canonical/config/tests/test_config_lookup.py 2010-01-08 04:12:19 +0000 |
| 4 | @@ -8,18 +8,17 @@ |
| 5 | |
| 6 | import os |
| 7 | import shutil |
| 8 | +from tempfile import mkdtemp, NamedTemporaryFile |
| 9 | import unittest |
| 10 | |
| 11 | -from tempfile import mkdtemp, NamedTemporaryFile |
| 12 | -from unittest import makeSuite, TestCase, TestSuite |
| 13 | - |
| 14 | -import lp.testing |
| 15 | - |
| 16 | from canonical import config |
| 17 | +from lp.testing import TestCase |
| 18 | + |
| 19 | |
| 20 | class TestConfigLookup(TestCase): |
| 21 | |
| 22 | def setUp(self): |
| 23 | + super(TestConfigLookup, self).setUp() |
| 24 | self.temp_lookup_file = None |
| 25 | self.original_CONFIG_LOOKUP_FILES = config.CONFIG_LOOKUP_FILES |
| 26 | self.original_LPCONFIG = os.environ['LPCONFIG'] |
| 27 | @@ -28,6 +27,7 @@ |
| 28 | del self.temp_lookup_file |
| 29 | config.CONFIG_LOOKUP_FILES = self.original_CONFIG_LOOKUP_FILES |
| 30 | os.environ['LPCONFIG'] = self.original_LPCONFIG |
| 31 | + super(TestConfigLookup, self).tearDown() |
| 32 | |
| 33 | def makeLookupFile(self): |
| 34 | self.temp_lookup_file = NamedTemporaryFile() |
| 35 | @@ -61,7 +61,7 @@ |
| 36 | config.find_instance_name(), config.DEFAULT_CONFIG) |
| 37 | |
| 38 | |
| 39 | -class ConfigTestCase(lp.testing.TestCase): |
| 40 | +class ConfigTestCase(TestCase): |
| 41 | """Base test case that provides fixtures for testing configuration. |
| 42 | """ |
| 43 | |
| 44 | @@ -79,7 +79,6 @@ |
| 45 | shutil.rmtree(self.temp_config_root_dir) |
| 46 | config.CONFIG_ROOT_DIRS = self.original_root_dirs |
| 47 | |
| 48 | - |
| 49 | def setUpInstanceConfig(self, instance_name): |
| 50 | """Create an instance directory with empty config files. |
| 51 | |
| 52 | @@ -104,6 +103,7 @@ |
| 53 | """Test where instance config directories are looked up.""" |
| 54 | |
| 55 | def setUp(self): |
| 56 | + super(TestInstanceConfigDirLookup, self).setUp() |
| 57 | self.setUpConfigRoots() |
| 58 | |
| 59 | def test_find_config_dir_raises_ValueError(self): |
| 60 | |
| 61 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py' |
| 62 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2009-10-27 14:36:03 +0000 |
| 63 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2010-01-08 04:12:19 +0000 |
| 64 | @@ -25,12 +25,14 @@ |
| 65 | |
| 66 | from lp.testing import TestCase, validate_mock_class |
| 67 | |
| 68 | + |
| 69 | class SubmissionParserTestParseSoftware(SubmissionParser): |
| 70 | """A Variant used to test SubmissionParser._parseSoftware. |
| 71 | |
| 72 | This class can be used to test the regular case of |
| 73 | submission data. |
| 74 | """ |
| 75 | + |
| 76 | def __init__(self, test, logger=None): |
| 77 | super(SubmissionParserTestParseSoftware, self).__init__(logger) |
| 78 | self.test = test |
| 79 | @@ -54,6 +56,7 @@ |
| 80 | This class is intended to test submission data that does not contain |
| 81 | a <xorg> node. |
| 82 | """ |
| 83 | + |
| 84 | def __init__(self, test, logger=None): |
| 85 | super(SubmissionParserTestParseSoftwareNoXorgNode, self).__init__( |
| 86 | logger) |
| 87 | @@ -74,6 +77,7 @@ |
| 88 | This class is intended to test submission data that does not contain |
| 89 | a <packages> node. |
| 90 | """ |
| 91 | + |
| 92 | def __init__(self, test, logger=None): |
| 93 | super(SubmissionParserTestParseSoftwareNoPackagesNode, self).__init__( |
| 94 | logger) |
| 95 | @@ -95,6 +99,7 @@ |
| 96 | |
| 97 | def setUp(self): |
| 98 | """Setup the test environment.""" |
| 99 | + super(TestHWDBSubmissionParser, self).setUp() |
| 100 | self.log = logging.getLogger('test_hwdb_submission_parser') |
| 101 | self.log.setLevel(logging.INFO) |
| 102 | self.handler = Handler(self) |
| 103 | @@ -250,7 +255,7 @@ |
| 104 | {'name': 'architecture_info', |
| 105 | 'version': '1.1'}, |
| 106 | {'name': 'find_network_controllers', |
| 107 | - 'version': '2.34'}]} |
| 108 | + 'version': '2.34'}]}, |
| 109 | } |
| 110 | self.assertEqual( |
| 111 | summary, expected_data, |
| 112 | @@ -293,7 +298,7 @@ |
| 113 | 'plugins': [ |
| 114 | { |
| 115 | 'name': 'architecture_info', |
| 116 | - 'version': '1.1' |
| 117 | + 'version': '1.1', |
| 118 | }, |
| 119 | { |
| 120 | 'name': 'find_network_controllers', |
| 121 | @@ -484,7 +489,6 @@ |
| 122 | """) |
| 123 | self.assertRaises(ValueError, parser._parseProperties, node) |
| 124 | |
| 125 | - |
| 126 | def testDevice(self): |
| 127 | """A device node is converted into a dictionary.""" |
| 128 | test = self |
| 129 | @@ -919,6 +923,7 @@ |
| 130 | |
| 131 | All "method substitutes" return a valid result. |
| 132 | """ |
| 133 | + |
| 134 | def __init__(self, logger=None): |
| 135 | super(self.__class__, self).__init__(logger) |
| 136 | self.hal_result = 'parsed HAL data' |
| 137 | @@ -1312,6 +1317,7 @@ |
| 138 | |
| 139 | All "method substitutes" return a valid result. |
| 140 | """ |
| 141 | + |
| 142 | def __init__(self, logger=None): |
| 143 | SubmissionParser.__init__(self, logger) |
| 144 | self.summary_result = 'parsed summary' |
| 145 | @@ -1363,8 +1369,8 @@ |
| 146 | 'summary': 'parsed summary', |
| 147 | 'hardware': 'parsed hardware', |
| 148 | 'software': 'parsed software', |
| 149 | - 'questions': 'parsed questions', |
| 150 | - 'context': 'parsed context', |
| 151 | + 'questions': 'parsed questions', |
| 152 | + 'context': 'parsed context', |
| 153 | } |
| 154 | |
| 155 | result = parser.parseMainSections(node) |
| 156 | @@ -1550,7 +1556,7 @@ |
| 157 | 'hardware': { |
| 158 | 'udev': udev, |
| 159 | 'sysfs-attributes': sysfs_attributes, |
| 160 | - 'processors': processors |
| 161 | + 'processors': processors, |
| 162 | }, |
| 163 | 'software': { |
| 164 | 'packages': packages |
| 165 | @@ -1579,7 +1585,7 @@ |
| 166 | ] |
| 167 | processors = [ |
| 168 | {'id': 1}, |
| 169 | - {'id': 2} |
| 170 | + {'id': 2}, |
| 171 | ] |
| 172 | packages = { |
| 173 | 'bzr': {'id': 4}, |
| 174 | @@ -1589,7 +1595,7 @@ |
| 175 | 'hardware': { |
| 176 | 'udev': udev, |
| 177 | 'sysfs-attributes': sysfs_attributes, |
| 178 | - 'processors': processors |
| 179 | + 'processors': processors, |
| 180 | }, |
| 181 | 'software': { |
| 182 | 'packages': packages |
| 183 | @@ -1646,7 +1652,7 @@ |
| 184 | submission = { |
| 185 | 'hardware': { |
| 186 | 'udev': devices, |
| 187 | - 'processors': processors |
| 188 | + 'processors': processors, |
| 189 | }, |
| 190 | 'software': { |
| 191 | 'packages': packages |
| 192 | @@ -1707,8 +1713,7 @@ |
| 193 | {'udi': DEVICE_2_UDI, |
| 194 | 'properties': { |
| 195 | 'info.parent': (ROOT_UDI, |
| 196 | - 'dbus.String')} |
| 197 | - }] |
| 198 | + 'dbus.String')}}] |
| 199 | |
| 200 | def testUDIDeviceMap(self): |
| 201 | """Test the creation of the mapping UDI -> device.""" |
| 202 | @@ -1893,7 +1898,7 @@ |
| 203 | 'properties': |
| 204 | {'info.parent': |
| 205 | (self.CIRCULAR_UDI_1, 'str')}} |
| 206 | - devices = [device1, device2, circular_device1, circular_device2] |
| 207 | + devices = [device1, device2, circular_device1, circular_device2] |
| 208 | parser = SubmissionParser() |
| 209 | udi_device_map = parser.getUDIDeviceMap(devices) |
| 210 | udi_children = parser.getUDIChildren(udi_device_map) |
| 211 | |
| 212 | === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py' |
| 213 | --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-11-05 15:12:46 +0000 |
| 214 | +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2010-01-08 04:12:19 +0000 |
| 215 | @@ -34,6 +34,7 @@ |
| 216 | |
| 217 | from lp.testing import TestCase, validate_mock_class |
| 218 | |
| 219 | + |
| 220 | class TestCaseHWDB(TestCase): |
| 221 | """Common base class for HWDB processing tests.""" |
| 222 | |
| 223 | @@ -91,6 +92,7 @@ |
| 224 | |
| 225 | def setUp(self): |
| 226 | """Setup the test environment.""" |
| 227 | + super(TestCaseHWDB, self).setUp() |
| 228 | self.log = logging.getLogger('test_hwdb_submission_parser') |
| 229 | self.log.setLevel(logging.INFO) |
| 230 | self.handler = Handler(self) |
| 231 | @@ -4534,6 +4536,7 @@ |
| 232 | |
| 233 | def setUp(self): |
| 234 | """Setup the test environment.""" |
| 235 | + super(TestHWDBSubmissionTablePopulation, self).setUp() |
| 236 | self.log = logging.getLogger('test_hwdb_submission_parser') |
| 237 | self.log.setLevel(logging.INFO) |
| 238 | self.handler = Handler(self) |
| 239 | |
| 240 | === modified file 'lib/canonical/launchpad/scripts/tests/test_runlaunchpad.py' |
| 241 | --- lib/canonical/launchpad/scripts/tests/test_runlaunchpad.py 2009-08-12 19:07:45 +0000 |
| 242 | +++ lib/canonical/launchpad/scripts/tests/test_runlaunchpad.py 2010-01-08 04:12:19 +0000 |
| 243 | @@ -6,7 +6,7 @@ |
| 244 | __metaclass__ = type |
| 245 | __all__ = [ |
| 246 | 'CommandLineArgumentProcessing', |
| 247 | - 'ServersToStart' |
| 248 | + 'ServersToStart', |
| 249 | ] |
| 250 | |
| 251 | |
| 252 | @@ -68,11 +68,11 @@ |
| 253 | split_out_runlaunchpad_arguments(['-o', 'foo', '--bar=baz'])) |
| 254 | |
| 255 | |
| 256 | - |
| 257 | class TestDefaultConfigArgument(lp.testing.TestCase): |
| 258 | """Tests for the processing of the -C argument.""" |
| 259 | |
| 260 | def setUp(self): |
| 261 | + super(TestDefaultConfigArgument, self).setUp() |
| 262 | self.config_root = tempfile.mkdtemp('configs') |
| 263 | self.saved_instance = config.instance_name |
| 264 | self.saved_config_roots = canonical.config.CONFIG_ROOT_DIRS |
| 265 | |
| 266 | === modified file 'lib/canonical/launchpad/webapp/tests/__init__.py' |
| 267 | --- lib/canonical/launchpad/webapp/tests/__init__.py 2009-08-20 13:32:32 +0000 |
| 268 | +++ lib/canonical/launchpad/webapp/tests/__init__.py 2010-01-08 04:12:19 +0000 |
| 269 | @@ -21,10 +21,11 @@ |
| 270 | """A test case that installs a DummyWebServiceConfiguration.""" |
| 271 | |
| 272 | def setUp(self): |
| 273 | + super(DummyConfigurationTestCase, self).setUp() |
| 274 | self.config = DummyWebServiceConfiguration() |
| 275 | provideUtility(self.config, IWebServiceConfiguration) |
| 276 | |
| 277 | def tearDown(self): |
| 278 | getGlobalSiteManager().unregisterUtility( |
| 279 | self.config, IWebServiceConfiguration) |
| 280 | - |
| 281 | + super(DummyConfigurationTestCase, self).tearDown() |
| 282 | |
| 283 | === modified file 'lib/canonical/launchpad/webapp/tests/test_dbpolicy.py' |
| 284 | --- lib/canonical/launchpad/webapp/tests/test_dbpolicy.py 2009-10-13 05:48:15 +0000 |
| 285 | +++ lib/canonical/launchpad/webapp/tests/test_dbpolicy.py 2010-01-08 04:12:19 +0000 |
| 286 | @@ -60,12 +60,14 @@ |
| 287 | policy = None |
| 288 | |
| 289 | def setUp(self): |
| 290 | + super(BaseDatabasePolicyTestCase, self).setUp() |
| 291 | if self.policy is None: |
| 292 | self.policy = BaseDatabasePolicy() |
| 293 | getUtility(IStoreSelector).push(self.policy) |
| 294 | |
| 295 | def tearDown(self): |
| 296 | getUtility(IStoreSelector).pop() |
| 297 | + super(BaseDatabasePolicyTestCase, self).tearDown() |
| 298 | |
| 299 | def test_correctly_implements_IDatabasePolicy(self): |
| 300 | self.assertProvides(self.policy, IDatabasePolicy) |
| 301 | @@ -77,7 +79,7 @@ |
| 302 | def setUp(self): |
| 303 | if self.policy is None: |
| 304 | self.policy = SlaveDatabasePolicy() |
| 305 | - BaseDatabasePolicyTestCase.setUp(self) |
| 306 | + super(SlaveDatabasePolicyTestCase, self).setUp() |
| 307 | |
| 308 | def test_defaults(self): |
| 309 | for store in ALL_STORES: |
| 310 | @@ -97,7 +99,7 @@ |
| 311 | |
| 312 | def setUp(self): |
| 313 | self.policy = SlaveOnlyDatabasePolicy() |
| 314 | - BaseDatabasePolicyTestCase.setUp(self) |
| 315 | + super(SlaveOnlyDatabasePolicyTestCase, self).setUp() |
| 316 | |
| 317 | def test_master_allowed(self): |
| 318 | for store in ALL_STORES: |
| 319 | @@ -111,7 +113,7 @@ |
| 320 | |
| 321 | def setUp(self): |
| 322 | self.policy = MasterDatabasePolicy() |
| 323 | - BaseDatabasePolicyTestCase.setUp(self) |
| 324 | + super(MasterDatabasePolicyTestCase, self).setUp() |
| 325 | |
| 326 | def test_XMLRPCRequest_uses_MasterPolicy(self): |
| 327 | """XMLRPC should always use the master flavor, since they always |
| 328 | @@ -139,10 +141,11 @@ |
| 329 | This test just checks the defaults, which is the same as the |
| 330 | slave policy for unauthenticated requests. |
| 331 | """ |
| 332 | + |
| 333 | def setUp(self): |
| 334 | request = LaunchpadTestRequest(SERVER_URL='http://launchpad.dev') |
| 335 | self.policy = LaunchpadDatabasePolicy(request) |
| 336 | - SlaveDatabasePolicyTestCase.setUp(self) |
| 337 | + super(LaunchpadDatabasePolicyTestCase, self).setUp() |
| 338 | |
| 339 | |
| 340 | class LayerDatabasePolicyTestCase(TestCase): |
| 341 | @@ -243,7 +246,7 @@ |
| 342 | |
| 343 | def setUp(self): |
| 344 | self.policy = ReadOnlyLaunchpadDatabasePolicy() |
| 345 | - BaseDatabasePolicyTestCase.setUp(self) |
| 346 | + super(ReadOnlyLaunchpadDatabasePolicyTestCase, self).setUp() |
| 347 | |
| 348 | def test_defaults(self): |
| 349 | # default Store is the slave. |
| 350 | |
| 351 | === modified file 'lib/canonical/launchpad/webapp/tests/test_menu.py' |
| 352 | --- lib/canonical/launchpad/webapp/tests/test_menu.py 2009-08-05 17:19:14 +0000 |
| 353 | +++ lib/canonical/launchpad/webapp/tests/test_menu.py 2010-01-08 04:12:19 +0000 |
| 354 | @@ -36,6 +36,7 @@ |
| 355 | |
| 356 | def tearDown(self): |
| 357 | logout() |
| 358 | + super(TestMenuBaseLinkCaching, self).tearDown() |
| 359 | |
| 360 | def test_no_cache_when_there_is_no_request(self): |
| 361 | # Calling login() would cause a new interaction to be setup with a |
| 362 | |
| 363 | === modified file 'lib/canonical/launchpad/webapp/tests/test_servers.py' |
| 364 | --- lib/canonical/launchpad/webapp/tests/test_servers.py 2009-09-17 14:23:16 +0000 |
| 365 | +++ lib/canonical/launchpad/webapp/tests/test_servers.py 2010-01-08 04:12:19 +0000 |
| 366 | @@ -418,7 +418,7 @@ |
| 367 | {'QUERY_STRING': "a=1&b=2&c=3", 'REQUEST_METHOD': 'POST'}) |
| 368 | self.assertEqual(request.method, 'POST') |
| 369 | self.assertEqual( |
| 370 | - {'a':['1'], 'b': ['2'], 'c': ['3']}, |
| 371 | + {'a': ['1'], 'b': ['2'], 'c': ['3']}, |
| 372 | request.query_string_params, |
| 373 | "The query_string_params dict is populated from the " |
| 374 | "QUERY_STRING during POST requests.") |
| 375 | @@ -461,4 +461,3 @@ |
| 376 | optionflags=NORMALIZE_WHITESPACE | ELLIPSIS)) |
| 377 | suite.addTest(unittest.TestLoader().loadTestsFromName(__name__)) |
| 378 | return suite |
| 379 | - |
| 380 | |
| 381 | === modified file 'lib/lp/archiveuploader/tests/test_buildduploads.py' |
| 382 | --- lib/lp/archiveuploader/tests/test_buildduploads.py 2009-08-28 07:34:44 +0000 |
| 383 | +++ lib/lp/archiveuploader/tests/test_buildduploads.py 2010-01-08 04:12:19 +0000 |
| 384 | @@ -70,7 +70,7 @@ |
| 385 | |
| 386 | real_policy = self.policy |
| 387 | self.policy = 'insecure' |
| 388 | - TestStagedBinaryUploadBase.setUp(self) |
| 389 | + super(TestBuilddUploads, self).setUp() |
| 390 | self.policy = real_policy |
| 391 | |
| 392 | def _publishBuildQueueItem(self, queue_item): |
| 393 | @@ -125,6 +125,6 @@ |
| 394 | build_used.title) |
| 395 | self.assertEqual('FULLYBUILT', build_used.buildstate.name) |
| 396 | |
| 397 | + |
| 398 | def test_suite(): |
| 399 | return unittest.TestLoader().loadTestsFromName(__name__) |
| 400 | - |
| 401 | |
| 402 | === modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py' |
| 403 | --- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2009-11-18 02:58:23 +0000 |
| 404 | +++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2010-01-08 04:12:19 +0000 |
| 405 | @@ -50,7 +50,7 @@ |
| 406 | Additionally to the TestUploadProcessorBase.setUp, set 'breezy' |
| 407 | distroseries and an new uploadprocessor instance. |
| 408 | """ |
| 409 | - TestUploadProcessorBase.setUp(self) |
| 410 | + super(TestPPAUploadProcessorBase, self).setUp() |
| 411 | self.ubuntu = getUtility(IDistributionSet).getByName('ubuntu') |
| 412 | # Let's make 'name16' person member of 'launchpad-beta-tester' |
| 413 | # team only in the context of this test. |
| 414 | |
| 415 | === modified file 'lib/lp/archiveuploader/tests/test_securityuploads.py' |
| 416 | --- lib/lp/archiveuploader/tests/test_securityuploads.py 2009-08-28 07:34:44 +0000 |
| 417 | +++ lib/lp/archiveuploader/tests/test_securityuploads.py 2010-01-08 04:12:19 +0000 |
| 418 | @@ -67,7 +67,7 @@ |
| 419 | 6. Clean log messages. |
| 420 | 7. Commit transaction, so the upload source can be seen. |
| 421 | """ |
| 422 | - TestUploadProcessorBase.setUp(self) |
| 423 | + super(TestStagedBinaryUploadBase, self).setUp() |
| 424 | self.options.context = self.policy |
| 425 | self.options.nomails = self.no_mails |
| 426 | # Set up the uploadprocessor with appropriate options and logger |
| 427 | @@ -164,7 +164,7 @@ |
| 428 | |
| 429 | def setUp(self): |
| 430 | """Setup base class and create the required new distroarchseries.""" |
| 431 | - TestStagedBinaryUploadBase.setUp(self) |
| 432 | + super(TestStagedSecurityUploads, self).setUp() |
| 433 | distribution = getUtility(IDistributionSet).getByName( |
| 434 | self.distribution_name) |
| 435 | distroseries = distribution[self.distroseries.name] |
| 436 | |
| 437 | === modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py' |
| 438 | --- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2009-11-18 02:58:23 +0000 |
| 439 | +++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-01-08 04:12:19 +0000 |
| 440 | @@ -107,7 +107,7 @@ |
| 441 | layer = LaunchpadZopelessLayer |
| 442 | |
| 443 | def setUp(self): |
| 444 | - TestCaseWithFactory.setUp(self) |
| 445 | + super(TestUploadProcessorBase, self).setUp() |
| 446 | |
| 447 | self.queue_folder = tempfile.mkdtemp() |
| 448 | os.makedirs(os.path.join(self.queue_folder, "incoming")) |
| 449 | @@ -134,6 +134,7 @@ |
| 450 | |
| 451 | def tearDown(self): |
| 452 | shutil.rmtree(self.queue_folder) |
| 453 | + super(TestUploadProcessorBase, self).tearDown() |
| 454 | |
| 455 | def assertLogContains(self, line): |
| 456 | """Assert if a given line is present in the log messages.""" |
| 457 | |
| 458 | === modified file 'lib/lp/code/browser/tests/test_branch.py' |
| 459 | --- lib/lp/code/browser/tests/test_branch.py 2009-11-13 21:16:15 +0000 |
| 460 | +++ lib/lp/code/browser/tests/test_branch.py 2010-01-08 04:12:19 +0000 |
| 461 | @@ -119,12 +119,13 @@ |
| 462 | layer = LaunchpadFunctionalLayer |
| 463 | |
| 464 | def setUp(self): |
| 465 | - TestCaseWithFactory.setUp(self) |
| 466 | + super(TestBranchView, self).setUp() |
| 467 | login(ANONYMOUS) |
| 468 | self.request = LaunchpadTestRequest() |
| 469 | |
| 470 | def tearDown(self): |
| 471 | logout() |
| 472 | + super(TestBranchView, self).tearDown() |
| 473 | |
| 474 | def testMirrorStatusMessageIsTruncated(self): |
| 475 | """mirror_status_message is truncated if the text is overly long.""" |
| 476 | @@ -238,13 +239,14 @@ |
| 477 | layer = DatabaseFunctionalLayer |
| 478 | |
| 479 | def setUp(self): |
| 480 | - TestCaseWithFactory.setUp(self) |
| 481 | + super(TestBranchAddView, self).setUp() |
| 482 | self.person = self.factory.makePerson() |
| 483 | login_person(self.person) |
| 484 | self.request = LaunchpadTestRequest() |
| 485 | |
| 486 | def tearDown(self): |
| 487 | logout() |
| 488 | + super(TestBranchAddView, self).tearDown() |
| 489 | |
| 490 | def get_view(self, context): |
| 491 | view = BranchAddView(context, self.request) |
| 492 | |
| 493 | === modified file 'lib/lp/code/mail/tests/test_codehandler.py' |
| 494 | --- lib/lp/code/mail/tests/test_codehandler.py 2009-10-23 19:33:09 +0000 |
| 495 | +++ lib/lp/code/mail/tests/test_codehandler.py 2010-01-08 04:12:19 +0000 |
| 496 | @@ -127,12 +127,13 @@ |
| 497 | layer = ZopelessAppServerLayer |
| 498 | |
| 499 | def setUp(self): |
| 500 | - TestCaseWithFactory.setUp(self, user='test@canonical.com') |
| 501 | + super(TestCodeHandler, self).setUp(user='test@canonical.com') |
| 502 | self.code_handler = CodeHandler() |
| 503 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
| 504 | |
| 505 | def tearDown(self): |
| 506 | setSecurityPolicy(self._old_policy) |
| 507 | + super(TestCodeHandler, self).tearDown() |
| 508 | |
| 509 | def switchDbUser(self, user): |
| 510 | """Commit the transactionand switch to the new user.""" |
| 511 | @@ -1060,6 +1061,7 @@ |
| 512 | # We don't need no stinking layer. |
| 513 | |
| 514 | def setUp(self): |
| 515 | + super(TestVoteEmailCommand, self).setUp() |
| 516 | class FakeExecutionContext: |
| 517 | vote = None |
| 518 | vote_tags = None |
| 519 | @@ -1149,7 +1151,8 @@ |
| 520 | layer = LaunchpadZopelessLayer |
| 521 | |
| 522 | def setUp(self): |
| 523 | - TestCaseWithFactory.setUp(self, user='test@canonical.com') |
| 524 | + super(TestUpdateStatusEmailCommand, self).setUp( |
| 525 | + user='test@canonical.com') |
| 526 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
| 527 | self.merge_proposal = self.factory.makeBranchMergeProposal() |
| 528 | # Default the user to be the target branch owner, so they are |
| 529 | @@ -1161,6 +1164,7 @@ |
| 530 | |
| 531 | def tearDown(self): |
| 532 | setSecurityPolicy(self._old_policy) |
| 533 | + super(TestUpdateStatusEmailCommand, self).tearDown() |
| 534 | |
| 535 | def test_numberOfArguments(self): |
| 536 | # The command needs one and only one arg. |
| 537 | @@ -1257,7 +1261,8 @@ |
| 538 | layer = LaunchpadZopelessLayer |
| 539 | |
| 540 | def setUp(self): |
| 541 | - TestCaseWithFactory.setUp(self, user='test@canonical.com') |
| 542 | + super(TestAddReviewerEmailCommand, self).setUp( |
| 543 | + user='test@canonical.com') |
| 544 | self._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy) |
| 545 | self.merge_proposal = self.factory.makeBranchMergeProposal() |
| 546 | # Default the user to be the target branch owner, so they are |
| 547 | @@ -1270,6 +1275,7 @@ |
| 548 | |
| 549 | def tearDown(self): |
| 550 | setSecurityPolicy(self._old_policy) |
| 551 | + super(TestAddReviewerEmailCommand, self).tearDown() |
| 552 | |
| 553 | def test_numberOfArguments(self): |
| 554 | # The command needs at least one arg. |
| 555 | |
| 556 | === modified file 'lib/lp/code/model/tests/test_branch.py' |
| 557 | --- lib/lp/code/model/tests/test_branch.py 2009-12-11 00:56:16 +0000 |
| 558 | +++ lib/lp/code/model/tests/test_branch.py 2010-01-08 04:12:19 +0000 |
| 559 | @@ -75,6 +75,7 @@ |
| 560 | layer = LaunchpadZopelessLayer |
| 561 | |
| 562 | def setUp(self): |
| 563 | + super(TestCodeImport, self).setUp() |
| 564 | login('test@canonical.com') |
| 565 | self.factory = LaunchpadObjectFactory() |
| 566 | |
| 567 | @@ -650,6 +651,7 @@ |
| 568 | layer = LaunchpadZopelessLayer |
| 569 | |
| 570 | def setUp(self): |
| 571 | + super(TestBranchDeletionConsequences, self).setUp() |
| 572 | login('test@canonical.com') |
| 573 | self.factory = LaunchpadObjectFactory() |
| 574 | # Has to be a product branch because of merge proposals. |
| 575 | @@ -1035,7 +1037,7 @@ |
| 576 | layer = DatabaseFunctionalLayer |
| 577 | |
| 578 | def setUp(self): |
| 579 | - TestCaseWithFactory.setUp(self, 'admin@canonical.com') |
| 580 | + super(BranchAddLandingTarget, self).setUp('admin@canonical.com') |
| 581 | self.product = self.factory.makeProduct() |
| 582 | |
| 583 | self.user = self.factory.makePerson() |
| 584 | @@ -1048,6 +1050,7 @@ |
| 585 | |
| 586 | def tearDown(self): |
| 587 | logout() |
| 588 | + super(BranchAddLandingTarget, self).tearDown() |
| 589 | |
| 590 | def test_junkSource(self): |
| 591 | """Junk branches cannot be used as a source for merge proposals.""" |
| 592 | |
| 593 | === modified file 'lib/lp/code/model/tests/test_codereviewkarma.py' |
| 594 | --- lib/lp/code/model/tests/test_codereviewkarma.py 2009-06-25 04:06:00 +0000 |
| 595 | +++ lib/lp/code/model/tests/test_codereviewkarma.py 2010-01-08 04:12:19 +0000 |
| 596 | @@ -29,7 +29,7 @@ |
| 597 | def setUp(self): |
| 598 | # Use an admin to get launchpad.Edit on all the branches to easily |
| 599 | # approve and reject the proposals. |
| 600 | - TestCaseWithFactory.setUp(self, 'admin@canonical.com') |
| 601 | + super(TestCodeReviewKarma, self).setUp('admin@canonical.com') |
| 602 | # The way the zope infrastructure works is that we can register |
| 603 | # subscribers easily, but there is no way to unregister them (bug |
| 604 | # 2338). TestEventListener does this with by setting a property to |
| 605 | @@ -46,6 +46,7 @@ |
| 606 | |
| 607 | def tearDown(self): |
| 608 | self.karma_listener.unregister() |
| 609 | + super(TestCodeReviewKarma, self).tearDown() |
| 610 | |
| 611 | def _on_karma_assigned(self, object, event): |
| 612 | # Store the karma event for checking in the test method. |
| 613 | |
| 614 | === modified file 'lib/lp/code/model/tests/test_revisionauthor.py' |
| 615 | --- lib/lp/code/model/tests/test_revisionauthor.py 2009-06-25 04:06:00 +0000 |
| 616 | +++ lib/lp/code/model/tests/test_revisionauthor.py 2010-01-08 04:12:19 +0000 |
| 617 | @@ -33,6 +33,7 @@ |
| 618 | layer = LaunchpadZopelessLayer |
| 619 | |
| 620 | def setUp(self): |
| 621 | + super(TestRevisionEmailExtraction, self).setUp() |
| 622 | LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser) |
| 623 | |
| 624 | def test_email_extracted_from_name(self): |
| 625 | @@ -132,6 +133,7 @@ |
| 626 | |
| 627 | def setUp(self): |
| 628 | # Create a revision author that doesn't have a user yet. |
| 629 | + super(TestNewlyValidatedEmailsLinkRevisionAuthors, self).setUp() |
| 630 | launchpad_dbuser = config.launchpad.dbuser |
| 631 | LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser) |
| 632 | self.author = RevisionSet()._createRevisionAuthor( |
| 633 | @@ -171,6 +173,7 @@ |
| 634 | layer = LaunchpadZopelessLayer |
| 635 | |
| 636 | def setUp(self): |
| 637 | + super(TestRevisionAuthor, self).setUp() |
| 638 | LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser) |
| 639 | |
| 640 | def testGetNameWithoutEmailReturnsNamePart(self): |
| 641 | |
| 642 | === modified file 'lib/lp/codehosting/puller/tests/test_worker.py' |
| 643 | --- lib/lp/codehosting/puller/tests/test_worker.py 2009-12-22 23:50:27 +0000 |
| 644 | +++ lib/lp/codehosting/puller/tests/test_worker.py 2010-01-08 04:12:19 +0000 |
| 645 | @@ -566,6 +566,7 @@ |
| 646 | """Tests specific to `MirroredBranchPolicy`.""" |
| 647 | |
| 648 | def setUp(self): |
| 649 | + super(TestMirroredBranchPolicy, self).setUp() |
| 650 | self.factory = LaunchpadObjectFactory() |
| 651 | |
| 652 | def testNoFileURL(self): |
| 653 | |
| 654 | === modified file 'lib/lp/codehosting/tests/test_rewrite.py' |
| 655 | --- lib/lp/codehosting/tests/test_rewrite.py 2009-11-05 19:06:56 +0000 |
| 656 | +++ lib/lp/codehosting/tests/test_rewrite.py 2010-01-08 04:12:19 +0000 |
| 657 | @@ -28,7 +28,7 @@ |
| 658 | layer = DatabaseFunctionalLayer |
| 659 | |
| 660 | def setUp(self): |
| 661 | - TestCaseWithFactory.setUp(self) |
| 662 | + super(TestBranchRewriter, self).setUp() |
| 663 | self.fake_time = FakeTime(0) |
| 664 | |
| 665 | def makeRewriter(self): |
| 666 | |
| 667 | === modified file 'lib/lp/registry/tests/test_distroseries.py' |
| 668 | --- lib/lp/registry/tests/test_distroseries.py 2009-08-28 07:34:44 +0000 |
| 669 | +++ lib/lp/registry/tests/test_distroseries.py 2010-01-08 04:12:19 +0000 |
| 670 | @@ -34,6 +34,7 @@ |
| 671 | |
| 672 | def setUp(self): |
| 673 | # Log in as an admin, so that we can create distributions. |
| 674 | + super(TestDistroSeriesCurrentSourceReleases, self).setUp() |
| 675 | login('foo.bar@canonical.com') |
| 676 | self.publisher = SoyuzTestPublisher() |
| 677 | self.factory = self.publisher.factory |
| 678 | |
| 679 | === modified file 'lib/lp/registry/tests/test_prf_walker.py' |
| 680 | --- lib/lp/registry/tests/test_prf_walker.py 2009-07-17 18:46:25 +0000 |
| 681 | +++ lib/lp/registry/tests/test_prf_walker.py 2010-01-08 04:12:19 +0000 |
| 682 | @@ -177,6 +177,7 @@ |
| 683 | |
| 684 | def tearDown(self): |
| 685 | reset_logging() |
| 686 | + super(WalkerBase_walk, self).tearDown() |
| 687 | |
| 688 | def test_walk_UnicodeEncodeError(self): |
| 689 | """Verify that a UnicodeEncodeError is logged.""" |
| 690 | @@ -311,6 +312,7 @@ |
| 691 | |
| 692 | def tearDown(self): |
| 693 | reset_logging() |
| 694 | + super(HTTPWalker_ListDir, self).tearDown() |
| 695 | |
| 696 | def setUpWalker(self, listing_url, listing_content): |
| 697 | from lp.registry.scripts.productreleasefinder.walker import ( |
| 698 | @@ -487,6 +489,7 @@ |
| 699 | |
| 700 | def tearDown(self): |
| 701 | reset_logging() |
| 702 | + super(HTTPWalker_IsDirectory, self).tearDown() |
| 703 | |
| 704 | def testFtpIsDirectory(self): |
| 705 | # Test that no requests are made by isDirectory() when walking |
| 706 | |
| 707 | === modified file 'lib/lp/scripts/utilities/tests/test_sanitizedb.py' |
| 708 | --- lib/lp/scripts/utilities/tests/test_sanitizedb.py 2009-10-01 03:54:04 +0000 |
| 709 | +++ lib/lp/scripts/utilities/tests/test_sanitizedb.py 2010-01-08 04:12:19 +0000 |
| 710 | @@ -20,6 +20,7 @@ |
| 711 | layer = DatabaseLayer |
| 712 | |
| 713 | def setUp(self): |
| 714 | + super(SanitizeDbScriptTestCase, self).setUp() |
| 715 | self.script_path = os.path.join( |
| 716 | config.root, 'utilities', 'sanitize-db.py') |
| 717 | DatabaseLayer.force_dirty_database() |
| 718 | |
| 719 | === modified file 'lib/lp/services/apachelogparser/tests/test_apachelogparser.py' |
| 720 | --- lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2009-11-17 18:36:20 +0000 |
| 721 | +++ lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2010-01-08 04:12:19 +0000 |
| 722 | @@ -230,6 +230,7 @@ |
| 723 | root = os.path.join(here, 'apache-log-files') |
| 724 | |
| 725 | def setUp(self): |
| 726 | + super(TestParsedFilesDetection, self).setUp() |
| 727 | self.layer.switchDbUser(DBUSER) |
| 728 | |
| 729 | def test_not_parsed_file(self): |
| 730 | @@ -301,6 +302,7 @@ |
| 731 | layer = LaunchpadZopelessLayer |
| 732 | |
| 733 | def setUp(self): |
| 734 | + super(Test_create_or_update_parsedlog_entry, self).setUp() |
| 735 | self.layer.switchDbUser(DBUSER) |
| 736 | |
| 737 | def test_creation_of_new_entries(self): |
| 738 | |
| 739 | === modified file 'lib/lp/services/database/tests/test_prejoin.py' |
| 740 | --- lib/lp/services/database/tests/test_prejoin.py 2009-10-28 12:38:31 +0000 |
| 741 | +++ lib/lp/services/database/tests/test_prejoin.py 2010-01-08 04:12:19 +0000 |
| 742 | @@ -20,6 +20,7 @@ |
| 743 | layer = LaunchpadZopelessLayer |
| 744 | |
| 745 | def setUp(self): |
| 746 | + super(PrejoinTestCase, self).setUp() |
| 747 | self.store = IMasterStore(Product) |
| 748 | |
| 749 | # All products |
| 750 | |
| 751 | === modified file 'lib/lp/services/mail/tests/test_mailbox.py' |
| 752 | --- lib/lp/services/mail/tests/test_mailbox.py 2009-06-30 16:56:07 +0000 |
| 753 | +++ lib/lp/services/mail/tests/test_mailbox.py 2010-01-08 04:12:19 +0000 |
| 754 | @@ -19,12 +19,10 @@ |
| 755 | class TestDirectoryMailBox(TestCase): |
| 756 | |
| 757 | def setUp(self): |
| 758 | + super(TestDirectoryMailBox, self).setUp() |
| 759 | # Create a temp directory. |
| 760 | self.email_dir = tempfile.mkdtemp() |
| 761 | - |
| 762 | - def tearDown(self): |
| 763 | - # Delete the directory. |
| 764 | - rmtree(self.email_dir) |
| 765 | + self.addCleanup(rmtree, self.email_dir) |
| 766 | |
| 767 | def test_verify_interface(self): |
| 768 | # Make sure that the object actually implements the interface. |
| 769 | |
| 770 | === modified file 'lib/lp/services/memcache/tests/test_memcache_client.py' |
| 771 | --- lib/lp/services/memcache/tests/test_memcache_client.py 2009-10-15 13:04:44 +0000 |
| 772 | +++ lib/lp/services/memcache/tests/test_memcache_client.py 2010-01-08 04:12:19 +0000 |
| 773 | @@ -18,6 +18,7 @@ |
| 774 | layer = LaunchpadZopelessLayer |
| 775 | |
| 776 | def setUp(self): |
| 777 | + super(MemcacheClientTestCase, self).setUp() |
| 778 | self.client = getUtility(IMemcacheClient) |
| 779 | |
| 780 | def test_basics(self): |
| 781 | |
| 782 | === modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py' |
| 783 | --- lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-12-21 12:54:47 +0000 |
| 784 | +++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-01-08 04:12:19 +0000 |
| 785 | @@ -1236,6 +1236,7 @@ |
| 786 | The records annotated will be excluded during the operation checks, |
| 787 | see checkCopies(). |
| 788 | """ |
| 789 | + super(CopyPackageTestCase, self).setUp() |
| 790 | pending_sources = SecureSourcePackagePublishingHistory.selectBy( |
| 791 | status=PackagePublishingStatus.PENDING) |
| 792 | self.sources_pending_ids = [pub.id for pub in pending_sources] |
| 793 | |
| 794 | === modified file 'lib/lp/translations/scripts/tests/test_remove_translations.py' |
| 795 | --- lib/lp/translations/scripts/tests/test_remove_translations.py 2009-10-17 14:06:03 +0000 |
| 796 | +++ lib/lp/translations/scripts/tests/test_remove_translations.py 2010-01-08 04:12:19 +0000 |
| 797 | @@ -45,6 +45,7 @@ |
| 798 | layer = LaunchpadZopelessLayer |
| 799 | |
| 800 | def setUp(self): |
| 801 | + super(TestRemoveTranslationsConstraints, self).setUp() |
| 802 | # Acquire privileges to delete TranslationMessages. We won't |
| 803 | # actually do that here, but we'll go through all the motions. |
| 804 | self.layer.switchDbUser('postgres') |
| 805 | @@ -155,6 +156,7 @@ |
| 806 | layer = LaunchpadZopelessLayer |
| 807 | |
| 808 | def setUp(self): |
| 809 | + super(TestRemoveTranslationsOptionsHandling, self).setUp() |
| 810 | self.factory = LaunchpadObjectFactory() |
| 811 | |
| 812 | def test_WithNativeArgs(self): |
| 813 | @@ -222,6 +224,7 @@ |
| 814 | layer = LaunchpadZopelessLayer |
| 815 | |
| 816 | def setUp(self): |
| 817 | + super(TestRemoveTranslations, self).setUp() |
| 818 | # Acquire privileges to delete TranslationMessages. That's not |
| 819 | # something we normally do. Actually we should test under |
| 820 | # rosettaadmin, but that user does not have all the privileges |
| 821 | @@ -553,6 +556,7 @@ |
| 822 | layer = LaunchpadZopelessLayer |
| 823 | |
| 824 | def setUp(self): |
| 825 | + super(TestRemoveTranslationsUnmasking, self).setUp() |
| 826 | self.layer.switchDbUser('postgres') |
| 827 | |
| 828 | # Set up a template with a Laotian translation file. There's |

This branch is pretty simple in intent. It goes through many, many test cases and makes them upcall setUp and tearDown.
It's a prequisite for using testtools, which mandates upcalling setUp & tearDown to avoid more painful errors.
I've also changed a lot of the upcalls to be new-style.