From 12d3063c95335950bbcf5184c6ff2fc83fa10c8e Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 6 Dec 2012 19:55:28 +0100 Subject: Add assert_true/false() functions. --- kconfigtest.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'kconfigtest.py') diff --git a/kconfigtest.py b/kconfigtest.py index adf2ce8..02c80b4 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -48,16 +48,16 @@ def run_selftests(): c["VISIBLE_STRING"], c["VISIBLE_INT"], c["VISIBLE_HEX"]): - if not s.is_modifiable(): - fail("{0} should be modifiable".format(s.get_name())) + assert_true(s.is_modifiable(), + "{0} should be modifiable".format(s.get_name())) for s in (c["NOT_VISIBLE"], c["SELECTED_TO_Y"], c["BOOL_SELECTED_TO_M"], c["NOT_VISIBLE_STRING"], c["NOT_VISIBLE_INT"], c["NOT_VISIBLE_HEX"]): - if s.is_modifiable(): - fail("{0} should not be modifiable".format(s.get_name())) + assert_false(s.is_modifiable(), + "{0} should not be modifiable".format(s.get_name())) print @@ -505,6 +505,16 @@ def equal_confs(): _all_ok = True +def assert_true(cond, msg): + """Fails and prints 'msg' if 'conf' is False.""" + if not cond: + fail(msg) + +def assert_false(cond, msg): + """Fails and prints 'msg' if 'conf' is True.""" + if cond: + fail(msg) + def fail(msg = None): global _all_ok if msg is not None: -- cgit v1.2.3