From b298d0d840059da1cdcbfe53a5a97242cd6883db Mon Sep 17 00:00:00 2001 From: ulif <uli@gnufix.de> Date: Sun, 1 May 2016 13:06:48 +0200 Subject: [PATCH] Add tests for handling "caps" markers. Try to cover all possibilities of `caps` related options when calling `handle_options()`. --- tests/test_diceware.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_diceware.py b/tests/test_diceware.py index 572f9a5..f4ae60c 100644 --- a/tests/test_diceware.py +++ b/tests/test_diceware.py @@ -151,6 +151,24 @@ class TestDicewareModule(object): options = handle_options(['--version', ]) assert options.version is True + def test_handle_options_caps(self): + # we can set a flag to tell use of caps + options = handle_options([]) + assert options.caps is True # default + options = handle_options(['-c', ]) + assert options.caps is True + options = handle_options(['--caps', ]) + assert options.caps is True + options = handle_options(['--no-caps', ]) + assert options.caps is False + + def test_handle_options_caps_conflicting_raises_exc(self): + # conflicting caps-settings raise an exception + with pytest.raises(SystemExit) as exc_info: + options = handle_options(['--caps', '--no-caps']) + with pytest.raises(SystemExit) as exc_info: + options = handle_options(['--no-caps', '--caps']) + def test_handle_options_delimiter(self): # we can set delimiter options = handle_options(['-d', ' ']) -- GitLab