summaryrefslogtreecommitdiff
blob: f6df14348c1a92646e089046a3e1f61a761228ea (plain)
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
51
# HG changeset patch
# User Vinay Sajip <vinay_sajip@yahoo.co.uk>
# Date 1528916733 -3600
# Node ID f16d4e17cf349cf9ee561e117262a4041e4fe2ee
# Parent  60ece27e564ef381392dc19a544aa289fb598c7e
Conditionally skip tests that rely on flaky external servers/networks.

diff --git a/gnupg.py b/gnupg.py
--- a/gnupg.py
+++ b/gnupg.py
@@ -1118,7 +1118,7 @@
         >>> gpg = GPG(gpgbinary=GPGBINARY, gnupghome="keys")
         >>> os.chmod('keys', 0x1C0)
         >>> result = gpg.recv_keys('pgp.mit.edu', '92905378')
-        >>> assert result
+        >>> if 'NO_EXTERNAL_TESTS' not in os.environ: assert result
 
         """
         result = self.result_map['import'](self)
@@ -1321,7 +1321,7 @@
         >>> gpg = GPG(gpgbinary=GPGBINARY, gnupghome='keys')
         >>> os.chmod('keys', 0x1C0)
         >>> result = gpg.search_keys('<vinay_sajip@hotmail.com>')
-        >>> assert result, 'Failed using default keyserver'
+        >>> if 'NO_EXTERNAL_TESTS' not in os.environ: assert result, 'Failed using default keyserver'
         >>> #keyserver = 'keyserver.ubuntu.com'
         >>> #result = gpg.search_keys('<vinay_sajip@hotmail.com>', keyserver)
         >>> #assert result, 'Failed using keyserver.ubuntu.com'
diff --git a/test_gnupg.py b/test_gnupg.py
--- a/test_gnupg.py
+++ b/test_gnupg.py
@@ -836,12 +836,13 @@
     #@skipIf(os.name == 'nt', 'Test not suitable for Windows')
     def test_search_keys(self):
         "Test that searching for keys works"
-        r = self.gpg.search_keys('<vinay_sajip@hotmail.com>')
-        self.assertTrue(r)
-        self.assertTrue('Vinay Sajip <vinay_sajip@hotmail.com>' in r[0]['uids'])
-        r = self.gpg.search_keys('92905378')
-        self.assertTrue(r)
-        self.assertTrue('Vinay Sajip <vinay_sajip@hotmail.com>' in r[0]['uids'])
+        if 'NO_EXTERNAL_TESTS' not in os.environ:
+            r = self.gpg.search_keys('<vinay_sajip@hotmail.com>')
+            self.assertTrue(r)
+            self.assertTrue('Vinay Sajip <vinay_sajip@hotmail.com>' in r[0]['uids'])
+            r = self.gpg.search_keys('92905378')
+            self.assertTrue(r)
+            self.assertTrue('Vinay Sajip <vinay_sajip@hotmail.com>' in r[0]['uids'])
 
     def test_quote_with_shell(self):
         "Test shell quoting with a real shell"