diff --git a/letsencrypt/tests/hook_test.py b/letsencrypt/tests/hook_test.py index 45025b054..6506eea2c 100644 --- a/letsencrypt/tests/hook_test.py +++ b/letsencrypt/tests/hook_test.py @@ -3,6 +3,7 @@ import os import unittest +import sys import mock @@ -76,10 +77,14 @@ class HookTest(unittest.TestCase): self.assertEqual(os.environ["RENEWED_DOMAINS"], "a b") self.assertEqual(os.environ["RENEWED_LINEAGE"], "thing") - with mock.patch("letsencrypt.hooks.print") as mock_print: - config = mock.MagicMock(renew_hook="true", dry_run=True) + config = mock.MagicMock(renew_hook="true", dry_run=True) + if sys.version_info < (2, 7): + # the print() function is not mockable in py26 self._test_a_hook(config, rhook, 0) - self.assertEqual(mock_print.call_count, 2) + else: + with mock.patch("letsencrypt.hooks.print") as mock_print: + self._test_a_hook(config, rhook, 0) + self.assertEqual(mock_print.call_count, 2) @mock.patch('letsencrypt.hooks.Popen') def test_run_hook(self, mock_popen):