mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:31:51 +02:00
Use a set for pre_hook.already
This commit is contained in:
+2
-2
@@ -54,11 +54,11 @@ def pre_hook(config):
|
|||||||
if cmd and cmd not in pre_hook.already:
|
if cmd and cmd not in pre_hook.already:
|
||||||
logger.info("Running pre-hook command: %s", cmd)
|
logger.info("Running pre-hook command: %s", cmd)
|
||||||
_run_hook(cmd)
|
_run_hook(cmd)
|
||||||
pre_hook.already[cmd] = True
|
pre_hook.already.add(cmd)
|
||||||
elif cmd:
|
elif cmd:
|
||||||
logger.info("Pre-hook command already run, skipping: %s", cmd)
|
logger.info("Pre-hook command already run, skipping: %s", cmd)
|
||||||
|
|
||||||
pre_hook.already = {}
|
pre_hook.already = set()
|
||||||
|
|
||||||
|
|
||||||
def post_hook(config):
|
def post_hook(config):
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class HookTest(unittest.TestCase):
|
|||||||
return mock_logger.warning
|
return mock_logger.warning
|
||||||
|
|
||||||
def test_pre_hook(self):
|
def test_pre_hook(self):
|
||||||
hooks.pre_hook.already = {}
|
hooks.pre_hook.already = set()
|
||||||
config = mock.MagicMock(pre_hook="true")
|
config = mock.MagicMock(pre_hook="true")
|
||||||
self._test_a_hook(config, hooks.pre_hook, 1)
|
self._test_a_hook(config, hooks.pre_hook, 1)
|
||||||
self._test_a_hook(config, hooks.pre_hook, 0)
|
self._test_a_hook(config, hooks.pre_hook, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user