From: Daira Hopwood Date: Mon, 27 Apr 2015 16:19:21 +0000 (+0100) Subject: test_drop_upload.py: factor out duplicated setting of self.inotify. X-Git-Url: https://git.rkrishnan.org/reliability?a=commitdiff_plain;h=bf563718ad2966c6e1230d2bde05e123b4c8da7a;p=tahoe-lafs%2Ftahoe-lafs.git test_drop_upload.py: factor out duplicated setting of self.inotify. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index 7ec55bec..348d53c1 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -297,6 +297,10 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA class MockTest(DropUploadTestMixin, unittest.TestCase): """This can run on any platform, and even if twisted.internet.inotify can't be imported.""" + def setUp(self): + DropUploadTestMixin.setUp(self) + self.inotify = fake_inotify + def notify_close_write(self, path): self.uploader._notifier.event(path, self.inotify.IN_CLOSE_WRITE) @@ -331,32 +335,26 @@ class MockTest(DropUploadTestMixin, unittest.TestCase): return d def test_drop_upload(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_drop_upload" return self._test() def test_basic_db(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_basic_db" return self._test_db_basic() def test_db_persistence(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_db_persistence" return self._test_db_persistence() def test_uploader_start_service(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_uploader_start_service" return self._test_uploader_start_service() def test_move_tree(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_move_tree" return self._test_move_tree() def test_persistence(self): - self.inotify = fake_inotify self.basedir = "drop_upload.MockTest.test_persistence" return self._test_persistence() @@ -364,13 +362,16 @@ class MockTest(DropUploadTestMixin, unittest.TestCase): class RealTest(DropUploadTestMixin, unittest.TestCase): """This is skipped unless both Twisted and the platform support inotify.""" + def setUp(self): + DropUploadTestMixin.setUp(self) + self.inotify = None + def test_drop_upload(self): # We should always have runtime.platform.supportsINotify, because we're using # Twisted >= 10.1. if sys.platform != "win32" and not runtime.platform.supportsINotify(): raise unittest.SkipTest("Drop-upload support can only be tested for-real on an OS that supports inotify or equivalent.") - self.inotify = None # use the appropriate inotify for the platform self.basedir = "drop_upload.RealTest.test_drop_upload" return self._test() @@ -379,26 +380,21 @@ class RealTest(DropUploadTestMixin, unittest.TestCase): pass def test_basic_db(self): - self.inotify = None self.basedir = "drop_upload.RealTest.test_basic_db" return self._test_db_basic() def test_db_persistence(self): - self.inotify = None self.basedir = "drop_upload.RealTest.test_db_persistence" return self._test_db_persistence() def test_uploader_start_service(self): - self.inotify = None self.basedir = "drop_upload.RealTest._test_uploader_start_service" return self._test_uploader_start_service() def test_move_tree(self): - self.inotify = None self.basedir = "drop_upload.RealTest._test_move_tree" return self._test_move_tree() def test_persistence(self): - self.inotify = None self.basedir = "drop_upload.RealTest.test_persistence" return self._test_persistence()