From 89d4811feda4cbeb1c4869d6485bca73474a6522 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 2 Jan 2022 13:06:08 +0100 Subject: [PATCH] documentation/python: ensure all plugin hooks are always tested. --- .../test_python/page_plugins/plugins/fancyline.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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) -- 2.30.2