mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 23:51:07 +00:00
Fix some setUp and tearDown
This commit is contained in:
parent
089c8d5626
commit
3814ccb947
@ -394,13 +394,17 @@ class NoNetworkGrid(service.MultiService):
|
|||||||
fileutil.rm_dir(os.path.join(server.sharedir, prefixdir))
|
fileutil.rm_dir(os.path.join(server.sharedir, prefixdir))
|
||||||
|
|
||||||
|
|
||||||
class GridTestMixin:
|
class GridTestMixin(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.s = service.MultiService()
|
self.s = service.MultiService()
|
||||||
self.s.startService()
|
self.s.startService()
|
||||||
|
return super(GridTestMixin, self).setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
return self.s.stopService()
|
return defer.gatherResults([
|
||||||
|
self.s.stopService(),
|
||||||
|
defer.maybeDeferred(super(GridTestMixin, self).tearDown),
|
||||||
|
])
|
||||||
|
|
||||||
def set_up_grid(self, num_clients=1, num_servers=10,
|
def set_up_grid(self, num_clients=1, num_servers=10,
|
||||||
client_config_hooks={}, oneshare=False):
|
client_config_hooks={}, oneshare=False):
|
||||||
|
@ -130,15 +130,18 @@ class Node(testutil.SignalMixin, testutil.ReallyEqualMixin, unittest.TestCase):
|
|||||||
self.failUnlessReallyEqual(w.staticdir, expected)
|
self.failUnlessReallyEqual(w.staticdir, expected)
|
||||||
|
|
||||||
|
|
||||||
class ServiceMixin:
|
class ServiceMixin(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.parent = LoggingMultiService()
|
self.parent = LoggingMultiService()
|
||||||
self.parent.startService()
|
self.parent.startService()
|
||||||
|
return super(ServiceMixin, self).setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
log.msg("TestIntroducer.tearDown")
|
log.msg("TestIntroducer.tearDown")
|
||||||
d = defer.succeed(None)
|
d = defer.succeed(None)
|
||||||
d.addCallback(lambda res: self.parent.stopService())
|
d.addCallback(lambda res: self.parent.stopService())
|
||||||
d.addCallback(flushEventualQueue)
|
d.addCallback(flushEventualQueue)
|
||||||
|
d.addCallback(lambda ignored: super(ServiceMixin, self).tearDown())
|
||||||
return d
|
return d
|
||||||
|
|
||||||
class Introducer(ServiceMixin, unittest.TestCase, pollmixin.PollMixin):
|
class Introducer(ServiceMixin, unittest.TestCase, pollmixin.PollMixin):
|
||||||
|
@ -66,7 +66,8 @@ class NewConfigUtilTests(TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
# some tests look at the umask of created directories or files
|
# some tests look at the umask of created directories or files
|
||||||
# so we set an explicit one
|
# so we set an explicit one
|
||||||
self._old_umask = os.umask(0o022)
|
old_umask = os.umask(0o022)
|
||||||
|
self.addCleanup(lambda: os.umask(old_umask))
|
||||||
self.basedir = abspath_expanduser_unicode(unicode(self.mktemp()))
|
self.basedir = abspath_expanduser_unicode(unicode(self.mktemp()))
|
||||||
os.mkdir(self.basedir)
|
os.mkdir(self.basedir)
|
||||||
self.local_dir = abspath_expanduser_unicode(unicode(self.mktemp()))
|
self.local_dir = abspath_expanduser_unicode(unicode(self.mktemp()))
|
||||||
@ -95,9 +96,7 @@ class NewConfigUtilTests(TestCase):
|
|||||||
)
|
)
|
||||||
# ..and the yaml
|
# ..and the yaml
|
||||||
self.write_magic_folder_config(self.basedir, self.folders)
|
self.write_magic_folder_config(self.basedir, self.folders)
|
||||||
|
return super(NewConfigUtilTests, self).setUp()
|
||||||
def tearDown(self):
|
|
||||||
os.umask(self._old_umask)
|
|
||||||
|
|
||||||
def write_tahoe_config(self, basedir, tahoe_config):
|
def write_tahoe_config(self, basedir, tahoe_config):
|
||||||
with open(join(basedir, u"tahoe.cfg"), "w") as f:
|
with open(join(basedir, u"tahoe.cfg"), "w") as f:
|
||||||
@ -302,6 +301,7 @@ class LegacyConfigUtilTests(TestCase):
|
|||||||
f.write("{}\n".format(self.magic_folder_dircap))
|
f.write("{}\n".format(self.magic_folder_dircap))
|
||||||
with open(join(privdir, "magicfolderdb.sqlite"), "w") as f:
|
with open(join(privdir, "magicfolderdb.sqlite"), "w") as f:
|
||||||
pass
|
pass
|
||||||
|
return super(LegacyConfigUtilTests, self).setUp()
|
||||||
|
|
||||||
def test_load_legacy_no_dir(self):
|
def test_load_legacy_no_dir(self):
|
||||||
expected = self.local_dir + 'foo'
|
expected = self.local_dir + 'foo'
|
||||||
@ -417,16 +417,13 @@ class MagicFolderDbTests(TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp = abspath_expanduser_unicode(unicode(self.mktemp()))
|
self.temp = abspath_expanduser_unicode(unicode(self.mktemp()))
|
||||||
os.mkdir(self.temp)
|
os.mkdir(self.temp)
|
||||||
|
self.addCleanup(lambda: shutil.rmtree(self.temp))
|
||||||
dbfile = abspath_expanduser_unicode(u"testdb.sqlite", base=self.temp)
|
dbfile = abspath_expanduser_unicode(u"testdb.sqlite", base=self.temp)
|
||||||
self.db = magicfolderdb.get_magicfolderdb(dbfile, create_version=(magicfolderdb.SCHEMA_v1, 1))
|
self.db = magicfolderdb.get_magicfolderdb(dbfile, create_version=(magicfolderdb.SCHEMA_v1, 1))
|
||||||
|
self.addCleanup(lambda: self.db.close())
|
||||||
self.failUnless(self.db, "unable to create magicfolderdb from %r" % (dbfile,))
|
self.failUnless(self.db, "unable to create magicfolderdb from %r" % (dbfile,))
|
||||||
self.failUnlessEqual(self.db.VERSION, 1)
|
self.failUnlessEqual(self.db.VERSION, 1)
|
||||||
|
return super(MagicFolderDbTests, self).setUp()
|
||||||
def tearDown(self):
|
|
||||||
if hasattr(self, 'db'):
|
|
||||||
self.db.close()
|
|
||||||
shutil.rmtree(self.temp)
|
|
||||||
return super(MagicFolderDbTests, self).tearDown()
|
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
self.db.did_upload_version(
|
self.db.did_upload_version(
|
||||||
|
Loading…
Reference in New Issue
Block a user