Fix tests on py26

the print() function does not appear to be mockable there
This commit is contained in:
Peter Eckersley
2016-03-31 09:57:57 -07:00
parent 8f8d80e7d1
commit 37c070597c
+8 -3
View File
@@ -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):