def test_parses_less_simple_comma_separated_lists(self): value = option_normalizer('F401 ,F402 ,F403 ,F404, F405', self.option, self.option_name) self.assertEqual(value, self.answer) value = option_normalizer('F401, F402, F403, F404, F405', self.option, self.option_name) self.assertEqual(value, self.answer)
def test_parses_less_simple_comma_separated_lists(self): value = option_normalizer('F401 ,F402 ,F403 ,F404', self.option, self.option_name) self.assertEqual(value, self.answer) value = option_normalizer('F401, F402, F403, F404', self.option, self.option_name) self.assertEqual(value, self.answer)
def test_parses_comma_separated_lists_with_newlines(self): value = option_normalizer('''\ F401, F402, F403, F404, ''', self.option, self.option_name) self.assertEqual(value, self.answer)
def test_parses_lists(self): answer = ['F401', 'F402', 'F403', 'F404'] option = option_normalizer('F401,F402,F403,F404') self.assertEqual(option, answer) option = option_normalizer('F401 ,F402 ,F403 ,F404') self.assertEqual(option, answer) option = option_normalizer('F401, F402, F403, F404') self.assertEqual(option, answer) option = option_normalizer('''\ F401, F402, F403, F404, ''') self.assertEqual(option, answer)
def finalize_options(self): self.options_dict = {} for (option_name, opt) in self.option_to_cmds.items(): if option_name in ['help', 'verbose']: continue value = getattr(self, option_name) if value is None: continue value = option_normalizer(value, opt, option_name) # Check if there's any values that need to be fixed. if option_name == "include" and isinstance(value, str): value = re.findall('[^,;\s]+', value) self.options_dict[option_name] = value
def test_on_is_true(self): value = option_normalizer('on', self.option, self.option_name) self.assertTrue(value)
def test_off_is_false(self): option = option_normalizer('off') self.assertFalse(option)
def test_OFF_is_false(self): value = option_normalizer('OFF', self.option, self.option_name) self.assertFalse(value)
def test_1_is_true(self): option = option_normalizer('1') self.assertTrue(option)
def test_false_is_false(self): option = option_normalizer('false') self.assertFalse(option)
def test_FALSE_is_false(self): option = option_normalizer('FALSE') self.assertFalse(option)
import optparse
def test_off_is_false(self): value = option_normalizer('off', self.option, self.option_name) self.assertFalse(value)
def test_FALSE_is_false(self): value = option_normalizer('FALSE', self.option, self.option_name) self.assertFalse(value)
def test_TRUE_is_true(self): value = option_normalizer('TRUE', self.option, self.option_name) self.assertTrue(value, True)
def test_parses_an_int(self): value = option_normalizer('2', self.option, self.option_name) self.assertEqual(value, 2)
# -*- coding: utf-8 -*-
def test_TRUE_is_true(self): option = option_normalizer('TRUE') self.assertTrue(option, True)
def test_OFF_is_false(self): option = option_normalizer('OFF') self.assertFalse(option)