예제 #1
0
    def test_for_getopt_get_values_with_short_form(self):
        c = config_manager.ConfigurationManager(
            use_admin_controls=True,
            #use_config_files=False,
            use_auto_help=False,
            argv_source=[])

        source = ['-l', '10']
        o = ValueSource(source)
        c.option_definitions.add_option('limit', default=0, short_form='l')
        self.assertEqual(o.get_values(c, False), {'limit': '10'})
        self.assertEqual(o.get_values(c, True), {'limit': '10'})
예제 #2
0
    def test_for_getopt_get_values_with_short_form(self):
        c = config_manager.ConfigurationManager(
          use_admin_controls=True,
          #use_config_files=False,
          use_auto_help=False,
          argv_source=[]
        )

        source = ['-l', '10']
        o = ValueSource(source)
        c.option_definitions.add_option('limit', default=0, short_form='l')
        self.assertEqual(o.get_values(c, False), {'limit': '10'})
        self.assertEqual(o.get_values(c, True), {'limit': '10'})
예제 #3
0
    def test_for_getopt_get_values(self):
        c = config_manager.ConfigurationManager(
            use_admin_controls=True,
            #use_config_files=False,
            use_auto_help=False,
            argv_source=[])

        source = ['--limit', '10']
        o = ValueSource(source)
        self.assertEqual(o.get_values(c, True), {})
        self.assertRaises(NotAnOptionError, o.get_values, c, False)

        c.option_definitions.add_option('limit', default=0)
        self.assertEqual(o.get_values(c, False), {'limit': '10'})
        self.assertEqual(o.get_values(c, True), {'limit': '10'})
        v = o.get_values(c, True, DotDict)
        self.assertTrue(isinstance(v, DotDict))
        v = o.get_values(c, True, DotDictWithAcquisition)
        self.assertTrue(isinstance(v, DotDictWithAcquisition))
예제 #4
0
    def test_for_getopt_get_values(self):
        c = config_manager.ConfigurationManager(
          use_admin_controls=True,
          #use_config_files=False,
          use_auto_help=False,
          argv_source=[]
        )

        source = ['--limit', '10']
        o = ValueSource(source)
        self.assertEqual(o.get_values(c, True), {})
        self.assertRaises(NotAnOptionError,
                          o.get_values, c, False)

        c.option_definitions.add_option('limit', default=0)
        self.assertEqual(o.get_values(c, False), {'limit': '10'})
        self.assertEqual(o.get_values(c, True), {'limit': '10'})
        v = o.get_values(c, True, DotDict)
        self.assertTrue(isinstance(v, DotDict))
        v = o.get_values(c, True, DotDictWithAcquisition)
        self.assertTrue(isinstance(v, DotDictWithAcquisition))
예제 #5
0
 def test_for_getopt_basics(self):
     source = ['a', 'b', 'c']
     o = ValueSource(source)
     self.assertEqual(o.argv_source, source)