1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# 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:
|