From: Leif Ryge <leif@synthesize.us>
Date: Sun, 12 Jan 2014 21:22:34 +0000 (+0000)
Subject: isolate test_keygen data
X-Git-Tag: allmydata-tahoe-1.10.1a1~202^2
X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/simplejson/cyclelanguage?a=commitdiff_plain;h=db43528430fea807c6cfebb97c7c9f1f500f58cc;p=tahoe-lafs%2Ftahoe-lafs.git

isolate test_keygen data

This makes test_keygen use its own basedir, to avoid polluting the _trial_temp
directory for later tests.
---

diff --git a/src/allmydata/key_generator.py b/src/allmydata/key_generator.py
index 89c8baff..63bf51b8 100644
--- a/src/allmydata/key_generator.py
+++ b/src/allmydata/key_generator.py
@@ -6,7 +6,7 @@ from foolscap.api import Referenceable, Tub
 from zope.interface import implements
 from twisted.internet import reactor
 from twisted.application import service
-from allmydata.util import log
+from allmydata.util import log, fileutil
 
 from pycryptopp.publickey import rsa
 from allmydata.interfaces import RIKeyGenerator
@@ -79,6 +79,7 @@ class KeyGeneratorService(service.MultiService):
     def __init__(self, basedir='.', display_furl=True, default_key_size=2048):
         service.MultiService.__init__(self)
         self.basedir = basedir
+        fileutil.make_dirs(self.basedir)
         self.tub = Tub(certFile=os.path.join(self.basedir, 'key_generator.pem'))
         self.tub.setOption("expose-remote-exception-types", False)
         self.tub.setServiceParent(self)
diff --git a/src/allmydata/test/test_keygen.py b/src/allmydata/test/test_keygen.py
index fe459cfb..71d7eafd 100644
--- a/src/allmydata/test/test_keygen.py
+++ b/src/allmydata/test/test_keygen.py
@@ -43,7 +43,7 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin):
 
         #print 'starting key generator service'
         keysize = TEST_RSA_KEY_SIZE
-        kgs = key_generator.KeyGeneratorService(display_furl=False, default_key_size=keysize)
+        kgs = key_generator.KeyGeneratorService(display_furl=False, default_key_size=keysize, basedir="key_generator_service")
         kgs.key_generator.verbose = True
         kgs.setServiceParent(self.parent)
         kgs.key_generator.pool_size = 8