From 741dce105dbf9d4118443f8d5ef588d43d6d8e45 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 12:44:29 -0300 Subject: On the mac, the tempdir is not created at /tmp, so checking the tempdir format instead --- mail/src/leap/mail/imap/tests/test_imap.py | 2 +- mail/src/leap/mail/smtp/tests/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mail/src/leap/mail/imap/tests/test_imap.py b/mail/src/leap/mail/imap/tests/test_imap.py index fd88440..e87eb7b 100644 --- a/mail/src/leap/mail/imap/tests/test_imap.py +++ b/mail/src/leap/mail/imap/tests/test_imap.py @@ -238,7 +238,7 @@ class IMAP4HelperMixin(BaseLeapTest): os.environ["PATH"] = cls.old_path os.environ["HOME"] = cls.old_home # safety check - assert cls.tempdir.startswith('/tmp/leap_tests-') + assert 'leap_tests-' in cls.tempdir shutil.rmtree(cls.tempdir) def setUp(self): diff --git a/mail/src/leap/mail/smtp/tests/__init__.py b/mail/src/leap/mail/smtp/tests/__init__.py index 1459cea..85419cb 100644 --- a/mail/src/leap/mail/smtp/tests/__init__.py +++ b/mail/src/leap/mail/smtp/tests/__init__.py @@ -148,7 +148,7 @@ class TestCaseWithKeyManager(BaseLeapTest): os.environ["PATH"] = self.old_path os.environ["HOME"] = self.old_home # safety check - assert self.tempdir.startswith('/tmp/leap_tests-') + assert 'leap_tests-' in self.tempdir shutil.rmtree(self.tempdir) -- cgit v1.2.3 From 43e5beb9b5bc886f89704c00f764da1feab4674c Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 12:54:10 -0300 Subject: Find the gpg binary on the system, even through symlinks --- mail/src/leap/mail/smtp/tests/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mail/src/leap/mail/smtp/tests/__init__.py b/mail/src/leap/mail/smtp/tests/__init__.py index 85419cb..5dc7465 100644 --- a/mail/src/leap/mail/smtp/tests/__init__.py +++ b/mail/src/leap/mail/smtp/tests/__init__.py @@ -21,6 +21,7 @@ Base classes and keys for SMTP gateway tests. """ import os +import distutils.spawn import shutil import tempfile from mock import Mock @@ -39,9 +40,14 @@ from leap.keymanager import ( from leap.common.testing.basetest import BaseLeapTest +def _find_gpg(): + gpg_path = distutils.spawn.find_executable('gpg') + return os.path.realpath(gpg_path) + + class TestCaseWithKeyManager(BaseLeapTest): - GPG_BINARY_PATH = '/usr/bin/gpg' + GPG_BINARY_PATH = _find_gpg() def setUp(self): # mimic BaseLeapTest.setUpClass behaviour, because this is deprecated -- cgit v1.2.3 From 592b7cbc561af91fed8e7d02b869ebe2f910b585 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Thu, 21 Aug 2014 15:05:33 -0300 Subject: Added fallback in case the gpg binary is not found on the PATH --- mail/src/leap/mail/smtp/tests/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mail/src/leap/mail/smtp/tests/__init__.py b/mail/src/leap/mail/smtp/tests/__init__.py index 5dc7465..dc24293 100644 --- a/mail/src/leap/mail/smtp/tests/__init__.py +++ b/mail/src/leap/mail/smtp/tests/__init__.py @@ -42,8 +42,8 @@ from leap.common.testing.basetest import BaseLeapTest def _find_gpg(): gpg_path = distutils.spawn.find_executable('gpg') - return os.path.realpath(gpg_path) - + return os.path.realpath(gpg_path) if gpg_path is not None else "/usr/bin/gpg" + class TestCaseWithKeyManager(BaseLeapTest): -- cgit v1.2.3