50 lines
1.8 KiB
Diff
50 lines
1.8 KiB
Diff
# HG changeset patch
|
|
# User Vinay Sajip <vinay_sajip@yahoo.co.uk>
|
|
# Date 1534104706 -3600
|
|
# Node ID aeb916c839c0f556dae96bb1136be760ccc19cfe
|
|
# Parent 1a5795e58fe216c1227a11d169dbe4c09c625d15
|
|
Fixed problem with a fixed 'keys' homedir on slow/busy systems (see PR #24).
|
|
|
|
diff --git a/test_gnupg.py b/test_gnupg.py
|
|
--- a/test_gnupg.py
|
|
+++ b/test_gnupg.py
|
|
@@ -173,11 +173,14 @@
|
|
|
|
class GPGTestCase(unittest.TestCase):
|
|
def setUp(self):
|
|
- hd = os.path.join(os.getcwd(), 'keys')
|
|
- if os.path.exists(hd):
|
|
- self.assertTrue(os.path.isdir(hd),
|
|
- "Not a directory: %s" % hd)
|
|
- shutil.rmtree(hd, ignore_errors=True)
|
|
+ if 'STATIC_TEST_HOMEDIR' not in os.environ:
|
|
+ hd = tempfile.mkdtemp(prefix='keys-')
|
|
+ else:
|
|
+ hd = os.path.join(os.getcwd(), 'keys')
|
|
+ if os.path.exists(hd):
|
|
+ self.assertTrue(os.path.isdir(hd),
|
|
+ "Not a directory: %s" % hd)
|
|
+ shutil.rmtree(hd, ignore_errors=True)
|
|
prepare_homedir(hd)
|
|
self.homedir = hd
|
|
self.gpg = gpg = gnupg.GPG(gnupghome=hd, gpgbinary=GPGBINARY)
|
|
@@ -193,6 +196,10 @@
|
|
data_file.write(os.urandom(5120 * 1024))
|
|
data_file.close()
|
|
|
|
+ def tearDown(self):
|
|
+ if 'STATIC_TEST_HOMEDIR' not in os.environ:
|
|
+ shutil.rmtree(self.homedir, ignore_errors=True)
|
|
+
|
|
def test_environment(self):
|
|
"Test the environment by ensuring that setup worked"
|
|
hd = self.homedir
|
|
@@ -373,7 +380,7 @@
|
|
# and the keyring file name has changed.
|
|
pkn = 'pubring.kbx'
|
|
skn = None
|
|
- hd = os.path.join(os.getcwd(), 'keys')
|
|
+ hd = self.homedir
|
|
if os.name == 'posix':
|
|
pkn = os.path.join(hd, pkn)
|
|
if skn:
|