diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-06 19:55:28 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-06 19:55:28 +0100 |
| commit | 12d3063c95335950bbcf5184c6ff2fc83fa10c8e (patch) | |
| tree | b3968b2a79e6f54dd4f86f809d7638acc8baa171 | |
| parent | 2cd87dcf083f16177a984cad2ecff4710bde05d0 (diff) | |
Add assert_true/false() functions.
| -rw-r--r-- | kconfigtest.py | 18 |
1 files changed, 14 insertions, 4 deletions
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: |
