Beispiel #1
0
    def test_wrong_dict_value(self):
        '''
		Testing argparser argument with wrong value
		'''

        with self.assertRaises(ValueError):
            simplifiedapp._populate_argparse_parser(argparse.ArgumentParser(),
                                                    {'wrong': 'very'})
Beispiel #2
0
    def test_wrong_subparser_structure(self):
        '''
		Testing argparser subparser with wrong structure
		'''

        with self.assertRaises(ValueError):
            simplifiedapp._populate_argparse_parser(argparse.ArgumentParser(),
                                                    {True: 'wrong, very'})
Beispiel #3
0
    def test_wrong_dict_key(self):
        '''
		Testing argparser with a wrong dict key
		'''

        with self.assertRaises(ValueError):
            simplifiedapp._populate_argparse_parser(
                argparse.ArgumentParser(), {
                    4: 'wrong',
                    5: {
                        'key': 'still wrong'
                    }
                })
Beispiel #4
0
    def test_set_defaults(self):
        '''
		Test argparser set_defaults
		'''

        fixture = {'something': 'useless'}
        result = simplifiedapp._populate_argparse_parser(
            argparse.ArgumentParser(), {False: fixture})
        self.assertArgparseParse(result, fixture)
Beispiel #5
0
    def test_empty_subparser(self):
        '''
		Test argparser with empty subparser
		'''

        fixture = {True: ({'help': 'Possible actions'}, {})}
        result = simplifiedapp._populate_argparse_parser(
            argparse.ArgumentParser(
                formatter_class=argparse.ArgumentDefaultsHelpFormatter),
            fixture)
        result_pattern = '.*^\s*positional arguments:\s*^\s*\{}\s+Possible\s+actions\s*$.*'
        self.assertArgparseHelpRegex(result, result_pattern)
Beispiel #6
0
    def test_simple_argument(self):
        '''
		Test argparser simple argument
		'''

        fixture = {
            'foo': {
                'default': 'initial value',
                'help': 'this will foo'
            }
        }
        result = simplifiedapp._populate_argparse_parser(
            argparse.ArgumentParser(
                formatter_class=argparse.ArgumentDefaultsHelpFormatter),
            fixture)
        result_pattern = '.*^\s*positional arguments:\s*^\s*foo\s+this\s+will\s+foo\s*$.*'
        self.assertArgparseHelpRegex(result, result_pattern)