From 34f8cbc09b56eb1eb8e8d6c08cbd491814890dbc Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Sun, 25 Jan 2015 22:12:33 +0000 Subject: [PATCH] Typos & tests --- tests/functional/test_init.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index a5ec608ef..b681ef4b8 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -24,6 +24,7 @@ Package to test the openlp.core.__init__ package. """ from optparse import Values import os +import sys from unittest import TestCase from unittest.mock import MagicMock, patch @@ -122,8 +123,23 @@ class TestInit(TestCase, TestMixin): options = ['-e', '-l', 'debug', '-pd', '-s', 'style', 'extra', 'qt', 'args'] # WHEN: Calling parse_options - resluts = parse_options(options) + results = parse_options(options) # THEN: A tuple should be returned with the parsed options and left over args - self.assertEqual(resluts, (Values({'no_error_form': True, 'dev_version': True, 'portable': True, + self.assertEqual(results, (Values({'no_error_form': True, 'dev_version': True, 'portable': True, + 'style': 'style', 'loglevel': 'debug'}), ['extra', 'qt', 'args'])) + + def parse_options_valid_argv_short_options_test(self): + """ + Test that parse_options parses valid short options correctly when passed through sys.argv + """ + # GIVEN: A list of valid options + options = ['-e', '-l', 'debug', '-pd', '-s', 'style', 'extra', 'qt', 'args'] + + # WHEN: Passing in the options through sys.argv and calling parse_args with None + with patch.object(sys, 'argv', options): + results = parse_options(None) + + # THEN: parse_args should return a tuple of valid options and of left over options that OpenLP does not use + self.assertEqual(results, (Values({'no_error_form': True, 'dev_version': True, 'portable': True, 'style': 'style', 'loglevel': 'debug'}), ['extra', 'qt', 'args']))