def testInvalidItem(self):
     decoder = option_decoders.ListDecoder(item_decoder=self._int_decoder,
                                           option=_OPTION)
     with self.assertRaises(errors.Config.InvalidValue) as cm:
         decoder.Decode([5, 4, 3.5], _COMPONENT, _FLAGS)
     self.assertEqual(str(cm.exception), (
         'Invalid test_component.test_option[2] value: "3.5" (of type "float"). '
         'Value must be one of the following types: int.'))
Пример #2
0
 def testNonListInputType(self):
   decoder = option_decoders.ListDecoder(item_decoder=self._int_decoder,
                                         option=_OPTION)
   with self.assertRaises(errors.Config.InvalidValue) as cm:
     decoder.Decode(5, _COMPONENT, _FLAGS)
   self.assertEqual(str(cm.exception), (
       'Invalid test_component.test_option value: "5" (of type "int"). '
       'Value must be one of the following types: list.'))
 def testNone(self):
     decoder = option_decoders.ListDecoder(item_decoder=self._int_decoder,
                                           none_ok=True,
                                           option=_OPTION)
     self.assertIsNone(decoder.Decode(None, _COMPONENT, _FLAGS))