From fc73c461f1a8acf3e09670e8f9429c7ef9d0b71f Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 27 May 2018 23:58:47 +0200 Subject: Provide lists with all menus and comments Handy e.g. when implementing advanced search features. --- testsuite.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index 9909e1e..1f0ef64 100644 --- a/testsuite.py +++ b/testsuite.py @@ -41,7 +41,7 @@ # All tests should pass. Report regressions to ulfalizer a.t Google's email # service. -from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, \ +from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, MenuNode, \ BOOL, TRISTATE, HEX, STRING, \ TRI_TO_STR, \ escape, unescape, \ @@ -957,6 +957,27 @@ g fail("recursive 'source' did not raise exception") + print("Testing Kconfig.choices/menus/comments") + + c = Kconfig("Kconfiglib/tests/Kitemlists") + + def verify_prompts(items, *expected_prompts): + verify(len(items) == len(expected_prompts), + "Wrong number of prompts for {}".format(items)) + + for item, expected_prompt in zip(items, expected_prompts): + if not isinstance(item, MenuNode): + item = item.nodes[0] + + verify(item.prompt[0] == expected_prompt, + "Wrong prompt for {}, expected '{}'" + .format(repr(item), expected_prompt)) + + verify_prompts(c.choices, "choice 1", "choice 2", "choice 3") + verify_prompts(c.menus, "menu 1", "menu 2", "menu 3", "menu 4", "menu 5") + verify_prompts(c.comments, "comment 1", "comment 2", "comment 3") + + print("Testing Symbol/Choice.direct_dep") c = Kconfig("Kconfiglib/tests/Kdirdep") -- cgit v1.2.3