Example #1
0
 def test_matches(self):
     result = base_utils.args_to_dict(
         ['aBc:DeF', 'SyS=DEf', 'XY_Z:', 'F__o0O=', 'B8r:=:=', '_bAZ_=:=:'])
     self.assertEqual(
         result, {
             'abc': 'DeF',
             'sys': 'DEf',
             'xy_z': '',
             'f__o0o': '',
             'b8r': '=:=',
             '_baz_': ':=:'
         })
    def test_unmatches(self):
        # Temporarily shut warning messages from args_to_dict() when an argument
        # doesn't match its pattern.
        logger = logging.getLogger()
        saved_level = logger.level
        logger.setLevel(logging.ERROR)

        try:
            result = base_utils.args_to_dict(['ab-c:DeF', '--SyS=DEf', 'a*=b', 'a*b',
                                         ':VAL', '=VVV', 'WORD'])
            self.assertEqual({}, result)
        finally:
            # Restore level.
            logger.setLevel(saved_level)
Example #3
0
 def test_matches(self):
     result = base_utils.args_to_dict(['aBc:DeF', 'SyS=DEf', 'XY_Z:',
                                  'F__o0O=', 'B8r:=:=', '_bAZ_=:=:'])
     self.assertEqual(result, {'abc':'DeF', 'sys':'DEf', 'xy_z':'',
                               'f__o0o':'', 'b8r':'=:=', '_baz_':':=:'})
 def test_no_args(self):
     result = base_utils.args_to_dict([])
     self.assertEqual({}, result)