diff options
Diffstat (limited to 'src/mailman_pgp/model/tests/test_list.py')
| -rw-r--r-- | src/mailman_pgp/model/tests/test_list.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mailman_pgp/model/tests/test_list.py b/src/mailman_pgp/model/tests/test_list.py index 9bb0a4e..eb43355 100644 --- a/src/mailman_pgp/model/tests/test_list.py +++ b/src/mailman_pgp/model/tests/test_list.py @@ -16,6 +16,8 @@ # this program. If not, see <http://www.gnu.org/licenses/>. """""" +import shutil +import unittest from os.path import exists from unittest import TestCase @@ -23,9 +25,9 @@ from mailman.app.lifecycle import create_list from mailman.interfaces.listmanager import IListManager from zope.component import getUtility -from mailman_pgp.config import config from mailman_pgp.database import mm_transaction from mailman_pgp.model.list import PGPMailingList +from mailman_pgp.testing.config import patch_config from mailman_pgp.testing.layers import PGPConfigLayer from mailman_pgp.testing.pgp import load_key @@ -50,9 +52,11 @@ class TestPGPMailingList(TestCase): getUtility(IListManager).delete(self.mlist) self.assertFalse(exists(key_path)) + @patch_config('keypairs', 'shred_command', 'shred') + @unittest.skipIf(shutil.which('shred') is None, 'No shred command.') def test_shred_key_command(self): - self.addCleanup(config.set, 'keypairs', 'shred_command', '') - config.set('keypairs', 'shred_command', 'shred') + # This really just hopes that the test env has some coreutils, that + # provide `shred` command with this behaviour. key_path = PGPMailingList.for_list(self.mlist).key_path with open(key_path, 'rb') as f: before = f.read() @@ -61,9 +65,8 @@ class TestPGPMailingList(TestCase): after = f.read() self.assertNotEqual(before, after) + @patch_config('keypairs', 'shred', 'no') def test_delete_key(self): - self.addCleanup(config.set, 'keypairs', 'shred', 'yes') - config.set('keypairs', 'shred', 'no') key_path = PGPMailingList.for_list(self.mlist).key_path getUtility(IListManager).delete(self.mlist) self.assertFalse(exists(key_path)) |
