Merge lp:~mandel/ubuntuone-client/fix-tests into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Tim Cole
Approved revision: 1152
Merged at revision: 1152
Proposed branch: lp:~mandel/ubuntuone-client/fix-tests
Merge into: lp:ubuntuone-client
Diff against target: 679 lines (+116/-20)
13 files modified
tests/platform/linux/eventlog/test_zglog.py (+4/-3)
tests/platform/linux/test_dbus.py (+2/-1)
tests/platform/linux/test_messaging.py (+5/-0)
tests/platform/linux/test_notification.py (+5/-0)
tests/platform/linux/test_unity.py (+3/-0)
tests/platform/linux/test_vm.py (+6/-2)
tests/platform/test_interaction_interfaces.py (+18/-8)
tests/status/test_aggregator.py (+18/-0)
tests/syncdaemon/test_action_queue.py (+18/-0)
tests/syncdaemon/test_logger.py (+11/-0)
tests/syncdaemon/test_pathlockingtree.py (+8/-0)
tests/syncdaemon/test_states.py (+16/-5)
tests/syncdaemon/test_status_listener.py (+2/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/fix-tests
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Tim Cole (community) Approve
Review via email: mp+80554@code.launchpad.net

Commit message

Use setUp and tearDown correctly with twisted.trial.

Description of the change

Use setUp and tearDown correctly with twisted.trial.

To post a comment you must log in.
Revision history for this message
Tim Cole (tcole) wrote :

A victory for more deterministic tests.

review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/platform/linux/eventlog/test_zglog.py'
--- tests/platform/linux/eventlog/test_zglog.py 2011-06-15 21:14:06 +0000
+++ tests/platform/linux/eventlog/test_zglog.py 2011-10-27 11:43:24 +0000
@@ -25,7 +25,7 @@
2525
26from distutils.spawn import find_executable26from distutils.spawn import find_executable
2727
28from twisted.internet.defer import Deferred28from twisted.internet import defer
29from zeitgeist.client import ZeitgeistClient29from zeitgeist.client import ZeitgeistClient
30from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation30from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
3131
@@ -92,8 +92,9 @@
92class ZeitgeistTestCase(DBusTwistedTestCase):92class ZeitgeistTestCase(DBusTwistedTestCase):
93 """Tests for the zeitgeist logging module."""93 """Tests for the zeitgeist logging module."""
9494
95 @defer.inlineCallbacks
95 def setUp(self):96 def setUp(self):
96 super(ZeitgeistTestCase, self).setUp()97 yield super(ZeitgeistTestCase, self).setUp()
97 zgdaemon = find_executable("zeitgeist-daemon")98 zgdaemon = find_executable("zeitgeist-daemon")
98 if not zgdaemon:99 if not zgdaemon:
99 raise NotFoundError("zeitgeist-daemon was not found.")100 raise NotFoundError("zeitgeist-daemon was not found.")
@@ -138,7 +139,7 @@
138 zg = ZeitgeistLogger()139 zg = ZeitgeistLogger()
139 self.assertNotEqual(zg.client, None)140 self.assertNotEqual(zg.client, None)
140141
141 d2 = Deferred()142 d2 = defer.Deferred()
142143
143 def logged(id_list):144 def logged(id_list):
144 """The event was logged to zeitgeist."""145 """The event was logged to zeitgeist."""
145146
=== modified file 'tests/platform/linux/test_dbus.py'
--- tests/platform/linux/test_dbus.py 2011-08-03 20:20:02 +0000
+++ tests/platform/linux/test_dbus.py 2011-10-27 11:43:24 +0000
@@ -2909,9 +2909,10 @@
2909 self._old_home = os.environ['HOME']2909 self._old_home = os.environ['HOME']
2910 os.environ['HOME'] = self.home_dir2910 os.environ['HOME'] = self.home_dir
29112911
2912 @defer.inlineCallbacks
2912 def tearDown(self):2913 def tearDown(self):
2913 os.environ['HOME'] = self._old_home2914 os.environ['HOME'] = self._old_home
2914 return DBusTwistedTestCase.tearDown(self)2915 yield super(FolderTests, self).tearDown()
29152916
2916 def _create_udf(self, id, node_id, suggested_path, subscribed=True):2917 def _create_udf(self, id, node_id, suggested_path, subscribed=True):
2917 """Create an UDF and returns it and the volume."""2918 """Create an UDF and returns it and the volume."""
29182919
=== modified file 'tests/platform/linux/test_messaging.py'
--- tests/platform/linux/test_messaging.py 2011-03-29 22:47:53 +0000
+++ tests/platform/linux/test_messaging.py 2011-10-27 11:43:24 +0000
@@ -23,6 +23,7 @@
2323
2424
25from mocker import Mocker, ANY25from mocker import Mocker, ANY
26from twisted.internet import defer
26from twisted.trial.unittest import TestCase27from twisted.trial.unittest import TestCase
2728
28from ubuntuone.platform.linux.messaging import Messaging, _server_callback29from ubuntuone.platform.linux.messaging import Messaging, _server_callback
@@ -42,10 +43,14 @@
42class MessagingTestCase(TestCase):43class MessagingTestCase(TestCase):
43 """Test the Messaging API."""44 """Test the Messaging API."""
4445
46 @defer.inlineCallbacks
45 def setUp(self):47 def setUp(self):
48 yield super(MessagingTestCase, self).setUp()
46 self.mocker = Mocker()49 self.mocker = Mocker()
4750
51 @defer.inlineCallbacks
48 def tearDown(self):52 def tearDown(self):
53 yield super(MessagingTestCase, self).tearDown()
49 self.mocker.restore()54 self.mocker.restore()
50 self.mocker.verify()55 self.mocker.verify()
5156
5257
=== modified file 'tests/platform/linux/test_notification.py'
--- tests/platform/linux/test_notification.py 2011-03-03 23:29:37 +0000
+++ tests/platform/linux/test_notification.py 2011-10-27 11:43:24 +0000
@@ -23,6 +23,7 @@
2323
2424
25from mocker import Mocker25from mocker import Mocker
26from twisted.internet import defer
26from twisted.trial.unittest import TestCase27from twisted.trial.unittest import TestCase
2728
28from ubuntuone.platform.linux.notification import Notification, ICON_NAME29from ubuntuone.platform.linux.notification import Notification, ICON_NAME
@@ -45,10 +46,14 @@
45class NotificationTestCase(TestCase):46class NotificationTestCase(TestCase):
46 """Test the Messaging API."""47 """Test the Messaging API."""
4748
49 @defer.inlineCallbacks
48 def setUp(self):50 def setUp(self):
51 yield super(NotificationTestCase, self).setUp()
49 self.mocker = Mocker()52 self.mocker = Mocker()
5053
54 @defer.inlineCallbacks
51 def tearDown(self):55 def tearDown(self):
56 yield super(NotificationTestCase, self).tearDown()
52 self.mocker.restore()57 self.mocker.restore()
53 self.mocker.verify()58 self.mocker.verify()
5459
5560
=== modified file 'tests/platform/linux/test_unity.py'
--- tests/platform/linux/test_unity.py 2011-07-06 20:41:33 +0000
+++ tests/platform/linux/test_unity.py 2011-10-27 11:43:24 +0000
@@ -18,6 +18,7 @@
1818
19"""Tests for the liblauncher interface."""19"""Tests for the liblauncher interface."""
2020
21from twisted.internet import defer
21from twisted.trial.unittest import TestCase22from twisted.trial.unittest import TestCase
2223
23from ubuntuone.platform.linux import launcher24from ubuntuone.platform.linux import launcher
@@ -55,8 +56,10 @@
5556
56 skip = None if launcher.use_libunity else "libunity not installed."57 skip = None if launcher.use_libunity else "libunity not installed."
5758
59 @defer.inlineCallbacks
58 def setUp(self):60 def setUp(self):
59 """Initialize this test instance."""61 """Initialize this test instance."""
62 yield super(LauncherTestCase, self).setUp()
60 self.patch(launcher.Unity, "LauncherEntry", FakeLauncherEntry)63 self.patch(launcher.Unity, "LauncherEntry", FakeLauncherEntry)
61 self.launcher = launcher.UbuntuOneLauncher()64 self.launcher = launcher.UbuntuOneLauncher()
6265
6366
=== modified file 'tests/platform/linux/test_vm.py'
--- tests/platform/linux/test_vm.py 2011-07-27 20:10:33 +0000
+++ tests/platform/linux/test_vm.py 2011-10-27 11:43:24 +0000
@@ -19,6 +19,8 @@
19import os19import os
20import uuid20import uuid
2121
22from twisted.internet import defer
23
22from contrib.testing.testcase import FakeMain, environ24from contrib.testing.testcase import FakeMain, environ
23from tests.syncdaemon.test_vm import MetadataTestCase, BaseVolumeManagerTests25from tests.syncdaemon.test_vm import MetadataTestCase, BaseVolumeManagerTests
24from ubuntuone.storageprotocol import request26from ubuntuone.storageprotocol import request
@@ -44,8 +46,9 @@
44class MetadataOldLayoutTests(MetadataTestCase):46class MetadataOldLayoutTests(MetadataTestCase):
45 """Tests for 'old' layouts and metadata upgrade"""47 """Tests for 'old' layouts and metadata upgrade"""
4648
49 @defer.inlineCallbacks
47 def setUp(self):50 def setUp(self):
48 MetadataTestCase.setUp(self)51 yield super(MetadataOldLayoutTests, self).setUp()
49 self.root_dir = os.path.join(self.u1_dir, 'My Files')52 self.root_dir = os.path.join(self.u1_dir, 'My Files')
50 self.shares_dir = os.path.join(self.u1_dir, 'Shared With Me')53 self.shares_dir = os.path.join(self.u1_dir, 'Shared With Me')
51 self.new_root_dir = self.u1_dir54 self.new_root_dir = self.u1_dir
@@ -451,8 +454,9 @@
451class MetadataNewLayoutTests(MetadataTestCase):454class MetadataNewLayoutTests(MetadataTestCase):
452 """Test for 'new' layout and metadata upgrade."""455 """Test for 'new' layout and metadata upgrade."""
453456
457 @defer.inlineCallbacks
454 def setUp(self):458 def setUp(self):
455 MetadataTestCase.setUp(self)459 yield super(MetadataNewLayoutTests, self).setUp()
456 self.share_md_dir = os.path.join(self.vm_data_dir, 'shares')460 self.share_md_dir = os.path.join(self.vm_data_dir, 'shares')
457 self.shared_md_dir = os.path.join(self.vm_data_dir, 'shared')461 self.shared_md_dir = os.path.join(self.vm_data_dir, 'shared')
458 self.home_dir = os.path.join(self.tmpdir, 'home', 'ubuntuonehacker')462 self.home_dir = os.path.join(self.tmpdir, 'home', 'ubuntuonehacker')
459463
=== modified file 'tests/platform/test_interaction_interfaces.py'
--- tests/platform/test_interaction_interfaces.py 2011-07-27 14:26:36 +0000
+++ tests/platform/test_interaction_interfaces.py 2011-10-27 11:43:24 +0000
@@ -18,15 +18,18 @@
18"""Test that the interaction_interfaces are correctly called."""18"""Test that the interaction_interfaces are correctly called."""
1919
20from mocker import MockerTestCase, MATCH20from mocker import MockerTestCase, MATCH
21from twisted.internet import defer
22
21from tests.platform import IPCTestCase23from tests.platform import IPCTestCase
2224
2325
24class TestStatusIPC(MockerTestCase, IPCTestCase):26class TestStatusIPC(MockerTestCase, IPCTestCase):
25 """Ensure that calls are correctly fowarded."""27 """Ensure that calls are correctly fowarded."""
2628
29 @defer.inlineCallbacks
27 def setUp(self):30 def setUp(self):
28 """Set up tests."""31 """Set up tests."""
29 super(TestStatusIPC, self).setUp()32 yield super(TestStatusIPC, self).setUp()
30 self.syncdaemon_status = self.mocker.mock()33 self.syncdaemon_status = self.mocker.mock()
31 self.status.syncdaemon_status = self.syncdaemon_status34 self.status.syncdaemon_status = self.syncdaemon_status
3235
@@ -82,9 +85,10 @@
82class TestEventsIPC(MockerTestCase, IPCTestCase):85class TestEventsIPC(MockerTestCase, IPCTestCase):
83 """Ensure that calls are correctly fowarded."""86 """Ensure that calls are correctly fowarded."""
8487
88 @defer.inlineCallbacks
85 def setUp(self):89 def setUp(self):
86 """Set up tests."""90 """Set up tests."""
87 super(TestEventsIPC, self).setUp()91 yield super(TestEventsIPC, self).setUp()
88 self.events_mock = self.mocker.mock()92 self.events_mock = self.mocker.mock()
89 self.events.events = self.events_mock93 self.events.events = self.events_mock
9094
@@ -100,9 +104,10 @@
100class TestSyncDaemonIPC(MockerTestCase, IPCTestCase):104class TestSyncDaemonIPC(MockerTestCase, IPCTestCase):
101 """Ensure that calls are correctly fowarded."""105 """Ensure that calls are correctly fowarded."""
102106
107 @defer.inlineCallbacks
103 def setUp(self):108 def setUp(self):
104 """Set up tests."""109 """Set up tests."""
105 super(TestSyncDaemonIPC, self).setUp()110 yield super(TestSyncDaemonIPC, self).setUp()
106 self.service = self.mocker.mock()111 self.service = self.mocker.mock()
107 self.sync.service = self.service112 self.sync.service = self.service
108113
@@ -174,9 +179,10 @@
174class TestFileSystemIPC(MockerTestCase, IPCTestCase):179class TestFileSystemIPC(MockerTestCase, IPCTestCase):
175 """Ensure that calls are correctly fowarded."""180 """Ensure that calls are correctly fowarded."""
176181
182 @defer.inlineCallbacks
177 def setUp(self):183 def setUp(self):
178 """Set up tests."""184 """Set up tests."""
179 super(TestFileSystemIPC, self).setUp()185 yield super(TestFileSystemIPC, self).setUp()
180 self.syncdaemon_filesystem = self.mocker.mock()186 self.syncdaemon_filesystem = self.mocker.mock()
181 self.fs.syncdaemon_filesystem = self.syncdaemon_filesystem187 self.fs.syncdaemon_filesystem = self.syncdaemon_filesystem
182188
@@ -221,9 +227,10 @@
221class TestSharesIPC(MockerTestCase, IPCTestCase):227class TestSharesIPC(MockerTestCase, IPCTestCase):
222 """Ensure that calls are correctly fowarded."""228 """Ensure that calls are correctly fowarded."""
223229
230 @defer.inlineCallbacks
224 def setUp(self):231 def setUp(self):
225 """Set up tests."""232 """Set up tests."""
226 super(TestSharesIPC, self).setUp()233 yield super(TestSharesIPC, self).setUp()
227 self.syncdaemon_shares = self.mocker.mock()234 self.syncdaemon_shares = self.mocker.mock()
228 self.shares.syncdaemon_shares = self.syncdaemon_shares235 self.shares.syncdaemon_shares = self.syncdaemon_shares
229236
@@ -316,9 +323,10 @@
316class TestConfigIPC(MockerTestCase, IPCTestCase):323class TestConfigIPC(MockerTestCase, IPCTestCase):
317 """Ensure that calls are correctly fowarded."""324 """Ensure that calls are correctly fowarded."""
318325
326 @defer.inlineCallbacks
319 def setUp(self):327 def setUp(self):
320 """Set up tests."""328 """Set up tests."""
321 super(TestConfigIPC, self).setUp()329 yield super(TestConfigIPC, self).setUp()
322 self.syncdaemon_config = self.mocker.mock()330 self.syncdaemon_config = self.mocker.mock()
323 self.config.syncdaemon_config = self.syncdaemon_config331 self.config.syncdaemon_config = self.syncdaemon_config
324332
@@ -467,9 +475,10 @@
467class TestFoldersIPC(MockerTestCase, IPCTestCase):475class TestFoldersIPC(MockerTestCase, IPCTestCase):
468 """Ensure that calls are correctly fowarded."""476 """Ensure that calls are correctly fowarded."""
469477
478 @defer.inlineCallbacks
470 def setUp(self):479 def setUp(self):
471 """Set up tests."""480 """Set up tests."""
472 super(TestFoldersIPC, self).setUp()481 yield super(TestFoldersIPC, self).setUp()
473 self.syncdaemon_folders = self.mocker.mock()482 self.syncdaemon_folders = self.mocker.mock()
474 self.folders.syncdaemon_folders = self.syncdaemon_folders483 self.folders.syncdaemon_folders = self.syncdaemon_folders
475484
@@ -528,9 +537,10 @@
528class TestPublicFilesIPC(MockerTestCase, IPCTestCase):537class TestPublicFilesIPC(MockerTestCase, IPCTestCase):
529 """Ensure that calls are correctly fowarded."""538 """Ensure that calls are correctly fowarded."""
530539
540 @defer.inlineCallbacks
531 def setUp(self):541 def setUp(self):
532 """Set up tests."""542 """Set up tests."""
533 super(TestPublicFilesIPC, self).setUp()543 yield super(TestPublicFilesIPC, self).setUp()
534 self.syncdaemon_public_files = self.mocker.mock()544 self.syncdaemon_public_files = self.mocker.mock()
535 self.public_files.syncdaemon_public_files =\545 self.public_files.syncdaemon_public_files =\
536 self.syncdaemon_public_files546 self.syncdaemon_public_files
537547
=== modified file 'tests/status/test_aggregator.py'
--- tests/status/test_aggregator.py 2011-09-21 14:12:25 +0000
+++ tests/status/test_aggregator.py 2011-10-27 11:43:24 +0000
@@ -50,8 +50,10 @@
5050
51 TIMEOUT = 3.051 TIMEOUT = 3.0
5252
53 @defer.inlineCallbacks
53 def setUp(self):54 def setUp(self):
54 """Initialize this test instance."""55 """Initialize this test instance."""
56 yield super(TimerTestCase, self).setUp()
55 self.clock = PatchedClock()57 self.clock = PatchedClock()
56 self.timer = aggregator.Timer(delay=3.0, clock=self.clock)58 self.timer = aggregator.Timer(delay=3.0, clock=self.clock)
5759
@@ -101,8 +103,10 @@
101103
102 DELAY = 0.5104 DELAY = 0.5
103105
106 @defer.inlineCallbacks
104 def setUp(self):107 def setUp(self):
105 """Initialize this test instance."""108 """Initialize this test instance."""
109 yield super(DeadlineTimerTestCase, self).setUp()
106 self.clock = PatchedClock()110 self.clock = PatchedClock()
107 self.timer = aggregator.DeadlineTimer(delay=0.5, timeout=3.0,111 self.timer = aggregator.DeadlineTimer(delay=0.5, timeout=3.0,
108 clock=self.clock)112 clock=self.clock)
@@ -242,8 +246,10 @@
242class ToggleableNotificationTestCase(TestCase):246class ToggleableNotificationTestCase(TestCase):
243 """Test the ToggleableNotification class."""247 """Test the ToggleableNotification class."""
244248
249 @defer.inlineCallbacks
245 def setUp(self):250 def setUp(self):
246 """Initialize this test instance."""251 """Initialize this test instance."""
252 yield super(ToggleableNotificationTestCase, self).setUp()
247 self.patch(aggregator, "Notification", FakeNotification)253 self.patch(aggregator, "Notification", FakeNotification)
248 self.notification_switch = aggregator.NotificationSwitch()254 self.notification_switch = aggregator.NotificationSwitch()
249 self.toggleable = self.notification_switch.get_notification()255 self.toggleable = self.notification_switch.get_notification()
@@ -282,8 +288,10 @@
282class NotificationSwitchTestCase(TestCase):288class NotificationSwitchTestCase(TestCase):
283 """Test the NotificationSwitch class."""289 """Test the NotificationSwitch class."""
284290
291 @defer.inlineCallbacks
285 def setUp(self):292 def setUp(self):
286 """Initialize this test instance."""293 """Initialize this test instance."""
294 yield super(NotificationSwitchTestCase, self).setUp()
287 self.notification_switch = aggregator.NotificationSwitch()295 self.notification_switch = aggregator.NotificationSwitch()
288296
289 def test_get_notification(self):297 def test_get_notification(self):
@@ -306,8 +314,10 @@
306class FileDiscoveryBubbleTestCase(TestCase):314class FileDiscoveryBubbleTestCase(TestCase):
307 """Test the FileDiscoveryBubble class."""315 """Test the FileDiscoveryBubble class."""
308316
317 @defer.inlineCallbacks
309 def setUp(self):318 def setUp(self):
310 """Initialize this test instance."""319 """Initialize this test instance."""
320 yield super(FileDiscoveryBubbleTestCase, self).setUp()
311 self.patch(aggregator, "ToggleableNotification",321 self.patch(aggregator, "ToggleableNotification",
312 FakeNotificationSingleton())322 FakeNotificationSingleton())
313 self.clock = PatchedClock()323 self.clock = PatchedClock()
@@ -487,8 +497,10 @@
487class FinalBubbleTestCase(TestCase):497class FinalBubbleTestCase(TestCase):
488 """Test for the final status notification bubble."""498 """Test for the final status notification bubble."""
489499
500 @defer.inlineCallbacks
490 def setUp(self):501 def setUp(self):
491 """Initialize this test instance."""502 """Initialize this test instance."""
503 yield super(FinalBubbleTestCase, self).setUp()
492 self.patch(aggregator, "ToggleableNotification",504 self.patch(aggregator, "ToggleableNotification",
493 FakeNotificationSingleton())505 FakeNotificationSingleton())
494 self.clock = PatchedClock()506 self.clock = PatchedClock()
@@ -542,8 +554,10 @@
542class ProgressBarTestCase(TestCase):554class ProgressBarTestCase(TestCase):
543 """Tests for the progress bar."""555 """Tests for the progress bar."""
544556
557 @defer.inlineCallbacks
545 def setUp(self):558 def setUp(self):
546 """Initialize this test instance."""559 """Initialize this test instance."""
560 yield super(ProgressBarTestCase, self).setUp()
547 self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher)561 self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher)
548 self.patch(aggregator.session, "Inhibitor", FakeInhibitor)562 self.patch(aggregator.session, "Inhibitor", FakeInhibitor)
549 self.clock = PatchedClock()563 self.clock = PatchedClock()
@@ -1035,8 +1049,10 @@
1035 CLASS_KWARGS = {}1049 CLASS_KWARGS = {}
1036 status = None1050 status = None
10371051
1052 @defer.inlineCallbacks
1038 def setUp(self):1053 def setUp(self):
1039 """Initialize this test instance."""1054 """Initialize this test instance."""
1055 yield super(StatusEventTestCase, self).setUp()
1040 if type(self) == StatusEventTestCase:1056 if type(self) == StatusEventTestCase:
1041 self.assertRaises(AssertionError, self.CLASS, **self.CLASS_KWARGS)1057 self.assertRaises(AssertionError, self.CLASS, **self.CLASS_KWARGS)
1042 else:1058 else:
@@ -1179,8 +1195,10 @@
1179class StatusAggregatorTestCase(TestCase):1195class StatusAggregatorTestCase(TestCase):
1180 """Test the backend of the status aggregator."""1196 """Test the backend of the status aggregator."""
11811197
1198 @defer.inlineCallbacks
1182 def setUp(self):1199 def setUp(self):
1183 """Initialize this test instance."""1200 """Initialize this test instance."""
1201 yield super(StatusAggregatorTestCase, self).setUp()
1184 self.patch(aggregator, "FileDiscoveryBubble",1202 self.patch(aggregator, "FileDiscoveryBubble",
1185 FakeFileDiscoveryBubble)1203 FakeFileDiscoveryBubble)
1186 self.patch(aggregator, "FinalStatusBubble",1204 self.patch(aggregator, "FinalStatusBubble",
11871205
=== modified file 'tests/syncdaemon/test_action_queue.py'
--- tests/syncdaemon/test_action_queue.py 2011-10-06 20:40:06 +0000
+++ tests/syncdaemon/test_action_queue.py 2011-10-27 11:43:24 +0000
@@ -283,6 +283,7 @@
283 @defer.inlineCallbacks283 @defer.inlineCallbacks
284 def tearDown(self):284 def tearDown(self):
285 """Cleanup."""285 """Cleanup."""
286 yield super(BasicTestCase, self).tearDown()
286 for record in self.handler.records:287 for record in self.handler.records:
287 exc_info = getattr(record, 'exc_info', None)288 exc_info = getattr(record, 'exc_info', None)
288 if exc_info is not None:289 if exc_info is not None:
@@ -442,8 +443,10 @@
442class TestRequestQueue(TwistedTestCase):443class TestRequestQueue(TwistedTestCase):
443 """Tests for the RequestQueue."""444 """Tests for the RequestQueue."""
444445
446 @defer.inlineCallbacks
445 def setUp(self):447 def setUp(self):
446 """Set up."""448 """Set up."""
449 yield super(TestRequestQueue, self).setUp()
447450
448 class FakeAQ(object):451 class FakeAQ(object):
449 """Fake AQ."""452 """Fake AQ."""
@@ -765,8 +768,10 @@
765class TestDeferredMap(TwistedTestCase):768class TestDeferredMap(TwistedTestCase):
766 """Test the deferred map."""769 """Test the deferred map."""
767770
771 @defer.inlineCallbacks
768 def setUp(self):772 def setUp(self):
769 """Set up."""773 """Set up."""
774 yield super(TestDeferredMap, self).setUp()
770 self.dm = DeferredMap()775 self.dm = DeferredMap()
771776
772 def test_one_get_returns_stored_deferred(self):777 def test_one_get_returns_stored_deferred(self):
@@ -853,8 +858,10 @@
853class TestZipQueue(TwistedTestCase):858class TestZipQueue(TwistedTestCase):
854 """Test the zipping queue."""859 """Test the zipping queue."""
855860
861 @defer.inlineCallbacks
856 def setUp(self):862 def setUp(self):
857 """Set up."""863 """Set up."""
864 yield super(TestZipQueue, self).setUp()
858 self.zq = ZipQueue()865 self.zq = ZipQueue()
859866
860 @defer.inlineCallbacks867 @defer.inlineCallbacks
@@ -5007,8 +5014,10 @@
5007class ActionQueueProtocolTests(TwistedTestCase):5014class ActionQueueProtocolTests(TwistedTestCase):
5008 """Test the ACQ class."""5015 """Test the ACQ class."""
50095016
5017 @defer.inlineCallbacks
5010 def setUp(self):5018 def setUp(self):
5011 """Set up."""5019 """Set up."""
5020 yield super(ActionQueueProtocolTests, self).setUp()
5012 # create an AQP and put a factory to it5021 # create an AQP and put a factory to it
5013 self.aqp = ActionQueueProtocol()5022 self.aqp = ActionQueueProtocol()
5014 obj = Mocker().mock()5023 obj = Mocker().mock()
@@ -5020,8 +5029,10 @@
5020 self.handler.setLevel(logging.DEBUG)5029 self.handler.setLevel(logging.DEBUG)
5021 self.aqp.log.addHandler(self.handler)5030 self.aqp.log.addHandler(self.handler)
50225031
5032 @defer.inlineCallbacks
5023 def tearDown(self):5033 def tearDown(self):
5024 """Tear down."""5034 """Tear down."""
5035 yield super(ActionQueueProtocolTests, self).tearDown()
5025 self.aqp.log.removeHandler(self.handler)5036 self.aqp.log.removeHandler(self.handler)
5026 if self.aqp.ping_manager is not None:5037 if self.aqp.ping_manager is not None:
5027 self.aqp.ping_manager.stop()5038 self.aqp.ping_manager.stop()
@@ -5629,8 +5640,10 @@
5629class ConditionsLockerTests(TwistedTestCase):5640class ConditionsLockerTests(TwistedTestCase):
5630 """Test the ConditionsLocker."""5641 """Test the ConditionsLocker."""
56315642
5643 @defer.inlineCallbacks
5632 def setUp(self):5644 def setUp(self):
5633 """Set up."""5645 """Set up."""
5646 yield super(ConditionsLockerTests, self).setUp()
5634 self.cl = ConditionsLocker()5647 self.cl = ConditionsLocker()
56355648
5636 def test_get_locking_deferred_returns_deferred(self):5649 def test_get_locking_deferred_returns_deferred(self):
@@ -5752,8 +5765,11 @@
5752class PingManagerTestCase(TwistedTestCase):5765class PingManagerTestCase(TwistedTestCase):
5753 """Test the Ping manager."""5766 """Test the Ping manager."""
57545767
5768 @defer.inlineCallbacks
5755 def setUp(self):5769 def setUp(self):
5756 """Set up."""5770 """Set up."""
5771 yield super(PingManagerTestCase, self).setUp()
5772
5757 class FakeActionQueueProtocol(object):5773 class FakeActionQueueProtocol(object):
5758 """Fake object for the tests."""5774 """Fake object for the tests."""
5759 log = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue")5775 log = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue")
@@ -5765,8 +5781,10 @@
5765 self.fake_aqp.log.addHandler(self.handler)5781 self.fake_aqp.log.addHandler(self.handler)
5766 self.pm = PingManager(self.fake_aqp)5782 self.pm = PingManager(self.fake_aqp)
57675783
5784 @defer.inlineCallbacks
5768 def tearDown(self):5785 def tearDown(self):
5769 """Tear down."""5786 """Tear down."""
5787 yield super(PingManagerTestCase, self).tearDown()
5770 self.fake_aqp.log.removeHandler(self.handler)5788 self.fake_aqp.log.removeHandler(self.handler)
5771 self.pm.stop()5789 self.pm.stop()
57725790
57735791
=== modified file 'tests/syncdaemon/test_logger.py'
--- tests/syncdaemon/test_logger.py 2011-08-10 12:01:01 +0000
+++ tests/syncdaemon/test_logger.py 2011-10-27 11:43:24 +0000
@@ -20,6 +20,7 @@
2020
21import logging21import logging
2222
23from twisted.internet import defer
23from twisted.trial import unittest24from twisted.trial import unittest
2425
25from ubuntuone.devtools.handlers import MementoHandler26from ubuntuone.devtools.handlers import MementoHandler
@@ -39,15 +40,19 @@
39class DebugCaptureTest(unittest.TestCase):40class DebugCaptureTest(unittest.TestCase):
40 """Tests for DebugCapture context manager."""41 """Tests for DebugCapture context manager."""
4142
43 @defer.inlineCallbacks
42 def setUp(self):44 def setUp(self):
43 """Setup the logger and the handler"""45 """Setup the logger and the handler"""
46 yield super(DebugCaptureTest, self).setUp()
44 self.handler = MementoHandler()47 self.handler = MementoHandler()
45 self.logger = logging.getLogger(self.__class__.__name__)48 self.logger = logging.getLogger(self.__class__.__name__)
46 self.logger.addHandler(self.handler)49 self.logger.addHandler(self.handler)
47 self.logger.setLevel(logging.DEBUG)50 self.logger.setLevel(logging.DEBUG)
4851
52 @defer.inlineCallbacks
49 def tearDown(self):53 def tearDown(self):
50 """close the handler and restore the logger (Logger's are global)"""54 """close the handler and restore the logger (Logger's are global)"""
55 yield super(DebugCaptureTest, self).tearDown()
51 self.handler.close()56 self.handler.close()
52 self.logger.removeHandler(self.handler)57 self.logger.removeHandler(self.handler)
53 self.logger.setLevel(logging.DEBUG)58 self.logger.setLevel(logging.DEBUG)
@@ -222,8 +227,10 @@
222class FilterTests(unittest.TestCase):227class FilterTests(unittest.TestCase):
223 """Tests log filters"""228 """Tests log filters"""
224229
230 @defer.inlineCallbacks
225 def setUp(self):231 def setUp(self):
226 """Setup the logger and the handler"""232 """Setup the logger and the handler"""
233 yield super(FilterTests, self).setUp()
227 self.handler = MementoHandler()234 self.handler = MementoHandler()
228 self.handler.setLevel(logging.DEBUG)235 self.handler.setLevel(logging.DEBUG)
229 root_logger.addHandler(self.handler)236 root_logger.addHandler(self.handler)
@@ -253,15 +260,19 @@
253class MultiFilterTest(unittest.TestCase):260class MultiFilterTest(unittest.TestCase):
254 """Tests for logger.MultiFilter"""261 """Tests for logger.MultiFilter"""
255262
263 @defer.inlineCallbacks
256 def setUp(self):264 def setUp(self):
257 """Setup the logger and the handler"""265 """Setup the logger and the handler"""
266 yield super(MultiFilterTest, self).setUp()
258 self.handler = MementoHandler()267 self.handler = MementoHandler()
259 self.logger = logging.getLogger(self.__class__.__name__)268 self.logger = logging.getLogger(self.__class__.__name__)
260 self.logger.addHandler(self.handler)269 self.logger.addHandler(self.handler)
261 self.logger.setLevel(logging.DEBUG)270 self.logger.setLevel(logging.DEBUG)
262271
272 @defer.inlineCallbacks
263 def tearDown(self):273 def tearDown(self):
264 """close the handler and restore the logger (Logger's are global)"""274 """close the handler and restore the logger (Logger's are global)"""
275 yield super(MultiFilterTest, self).tearDown()
265 self.handler.close()276 self.handler.close()
266 self.logger.removeHandler(self.handler)277 self.logger.removeHandler(self.handler)
267 self.logger.setLevel(logging.DEBUG)278 self.logger.setLevel(logging.DEBUG)
268279
=== modified file 'tests/syncdaemon/test_pathlockingtree.py'
--- tests/syncdaemon/test_pathlockingtree.py 2011-01-20 21:27:24 +0000
+++ tests/syncdaemon/test_pathlockingtree.py 2011-10-27 11:43:24 +0000
@@ -29,8 +29,10 @@
29class InternalDeferredTests(TwistedTestCase):29class InternalDeferredTests(TwistedTestCase):
30 """Test the internal deferreds handling functionality."""30 """Test the internal deferreds handling functionality."""
3131
32 @defer.inlineCallbacks
32 def setUp(self):33 def setUp(self):
33 """Set up."""34 """Set up."""
35 yield super(InternalDeferredTests, self).setUp()
34 self.plt = PathLockingTree()36 self.plt = PathLockingTree()
3537
36 def test_single_element_old(self):38 def test_single_element_old(self):
@@ -217,8 +219,10 @@
217class LockingTests(TwistedTestCase):219class LockingTests(TwistedTestCase):
218 """Test the locking between elements."""220 """Test the locking between elements."""
219221
222 @defer.inlineCallbacks
220 def setUp(self):223 def setUp(self):
221 """Set up."""224 """Set up."""
225 yield super(LockingTests, self).setUp()
222 self.plt = PathLockingTree()226 self.plt = PathLockingTree()
223227
224 @defer.inlineCallbacks228 @defer.inlineCallbacks
@@ -417,8 +421,10 @@
417class CleaningTests(TwistedTestCase):421class CleaningTests(TwistedTestCase):
418 """Test that the releases clean the tree."""422 """Test that the releases clean the tree."""
419423
424 @defer.inlineCallbacks
420 def setUp(self):425 def setUp(self):
421 """Set up."""426 """Set up."""
427 yield super(CleaningTests, self).setUp()
422 self.plt = PathLockingTree()428 self.plt = PathLockingTree()
423429
424 @defer.inlineCallbacks430 @defer.inlineCallbacks
@@ -547,8 +553,10 @@
547class LoggingTests(TwistedTestCase):553class LoggingTests(TwistedTestCase):
548 """Test the logging."""554 """Test the logging."""
549555
556 @defer.inlineCallbacks
550 def setUp(self):557 def setUp(self):
551 """Set up."""558 """Set up."""
559 yield super(LoggingTests, self).setUp()
552 self.plt = PathLockingTree()560 self.plt = PathLockingTree()
553561
554 self.handler = MementoHandler()562 self.handler = MementoHandler()
555563
=== modified file 'tests/syncdaemon/test_states.py'
--- tests/syncdaemon/test_states.py 2011-01-18 20:25:54 +0000
+++ tests/syncdaemon/test_states.py 2011-10-27 11:43:24 +0000
@@ -107,7 +107,9 @@
107class Base(TwistedTestCase):107class Base(TwistedTestCase):
108 """Base class for state tests."""108 """Base class for state tests."""
109109
110 @defer.inlineCallbacks
110 def setUp(self):111 def setUp(self):
112 yield super(Base, self).setUp()
111 # create fake classes113 # create fake classes
112 self.eq = FakeEventQueue()114 self.eq = FakeEventQueue()
113 self.aq = FakeActionQueue()115 self.aq = FakeActionQueue()
@@ -157,15 +159,18 @@
157 reactor.callLater(.1, check, 0)159 reactor.callLater(.1, check, 0)
158 return d160 return d
159161
162 @defer.inlineCallbacks
160 def tearDown(self):163 def tearDown(self):
164 yield super(Base, self).tearDown()
161 self.sm.connection.shutdown()165 self.sm.connection.shutdown()
162166
163167
164class QueueBase(Base):168class QueueBase(Base):
165 """Basic setup for QueueManager."""169 """Basic setup for QueueManager."""
166170
171 @defer.inlineCallbacks
167 def setUp(self):172 def setUp(self):
168 Base.setUp(self)173 yield super(QueueBase, self).setUp()
169 self.sm.state = StateManager.QUEUE_MANAGER174 self.sm.state = StateManager.QUEUE_MANAGER
170175
171176
@@ -223,8 +228,9 @@
223class TestConnectionManager(Base):228class TestConnectionManager(Base):
224 """Test the "internal network" transitions."""229 """Test the "internal network" transitions."""
225230
231 @defer.inlineCallbacks
226 def setUp(self):232 def setUp(self):
227 Base.setUp(self)233 yield super(TestConnectionManager, self).setUp()
228234
229 # put SM on some state that does not generate further235 # put SM on some state that does not generate further
230 # transition-related efforts for this CM236 # transition-related efforts for this CM
@@ -341,8 +347,9 @@
341class TestConnectionManagerTimings(Base):347class TestConnectionManagerTimings(Base):
342 """Times handled by ConnectionManager."""348 """Times handled by ConnectionManager."""
343349
350 @defer.inlineCallbacks
344 def setUp(self):351 def setUp(self):
345 Base.setUp(self)352 yield super(TestConnectionManagerTimings, self).setUp()
346353
347 # set timeout values to really low, to make tests run quicker354 # set timeout values to really low, to make tests run quicker
348 self.sm.connection.handshake_timeout = 0355 self.sm.connection.handshake_timeout = 0
@@ -843,8 +850,10 @@
843class TestStateManagerPassToNetworkManager(Base):850class TestStateManagerPassToNetworkManager(Base):
844 """All network events should go to NetworkManager."""851 """All network events should go to NetworkManager."""
845852
853 @defer.inlineCallbacks
846 def setUp(self):854 def setUp(self):
847 Base.setUp(self)855 yield super(TestStateManagerPassToNetworkManager,
856 self).setUp()
848857
849 # put a function in the middle to log calls858 # put a function in the middle to log calls
850 self.called_events = []859 self.called_events = []
@@ -893,8 +902,10 @@
893class TestStateManagerPassToQueueManager(Base):902class TestStateManagerPassToQueueManager(Base):
894 """All queue events should go to QueueManager."""903 """All queue events should go to QueueManager."""
895904
905 @defer.inlineCallbacks
896 def setUp(self):906 def setUp(self):
897 Base.setUp(self)907 yield super(TestStateManagerPassToQueueManager,
908 self).setUp()
898909
899 # put a function in the middle to log calls910 # put a function in the middle to log calls
900 self.called_events = []911 self.called_events = []
901912
=== modified file 'tests/syncdaemon/test_status_listener.py'
--- tests/syncdaemon/test_status_listener.py 2011-09-21 14:12:25 +0000
+++ tests/syncdaemon/test_status_listener.py 2011-10-27 11:43:24 +0000
@@ -96,9 +96,10 @@
96class StatusListenerTestCase(FakeMainTestCase):96class StatusListenerTestCase(FakeMainTestCase):
97 """Tests for StatusListener."""97 """Tests for StatusListener."""
9898
99 @defer.inlineCallbacks
99 def setUp(self):100 def setUp(self):
100 """Initialize this instance."""101 """Initialize this instance."""
101 super(StatusListenerTestCase, self).setUp()102 yield super(StatusListenerTestCase, self).setUp()
102 self.status_frontend = FakeStatusFrontend()103 self.status_frontend = FakeStatusFrontend()
103 self.listener = status_listener.StatusListener(self.fs, self.vm,104 self.listener = status_listener.StatusListener(self.fs, self.vm,
104 self.status_frontend)105 self.status_frontend)

Subscribers

People subscribed via source and target branches