mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 00:35:50 +02:00
Fix tests on py26
the print() function does not appear to be mockable there
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user