From: Vladimír Vondruš Date: Sun, 2 Jan 2022 12:06:08 +0000 (+0100) Subject: documentation/python: ensure all plugin hooks are always tested. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=89d4811feda4cbeb1c4869d6485bca73474a6522;p=blog.git documentation/python: ensure all plugin hooks are always tested. --- diff --git a/documentation/test_python/page_plugins/plugins/fancyline.py b/documentation/test_python/page_plugins/plugins/fancyline.py index c71995a3..b7f2894b 100644 --- a/documentation/test_python/page_plugins/plugins/fancyline.py +++ b/documentation/test_python/page_plugins/plugins/fancyline.py @@ -69,7 +69,16 @@ def _post_run(**kwargs): global post_run_call_count post_run_call_count = post_run_call_count + 1 -def register_mcss(hooks_post_crawl, hooks_pre_scope, hooks_post_scope, hooks_docstring, hooks_pre_page, hooks_post_run, **kwargs): +def register_mcss( + # The * is to ensure all arguments are passed as keyword + *, hooks_post_crawl, hooks_pre_scope, hooks_post_scope, hooks_docstring, hooks_pre_page, hooks_post_run, + # These are not used here, but requiring them to ensure these get passed + # always + mcss_settings, jinja_environment, module_doc_contents, class_doc_contents, enum_doc_contents, enum_value_doc_contents, function_doc_contents, property_doc_contents, data_doc_contents, + # This is asserted to be empty below to ensure the test is always updated + # for newly added hooks + **kwargs) \ +: hooks_post_crawl += [_post_crawl] hooks_pre_scope += [_pre_scope] hooks_post_scope += [_post_scope] @@ -77,4 +86,7 @@ def register_mcss(hooks_post_crawl, hooks_pre_scope, hooks_post_scope, hooks_doc hooks_pre_page += [_pre_page] hooks_post_run += [_post_run] + # To ensure the test is always updated for newly added hooks + assert not kwargs, "Expected empty kwargs but got %s" % kwargs + rst.directives.register_directive('fancy-line', FancyLine)