예제 #1
0
class MyConfig(DummyMemoryConfig):
    test_array = ArrayOption('TestArray',
                             env_name='TEST_ARRAY',
                             default=["1", "2", "3"])
    path_array = ArrayOption('PathArray',
                             value_option=PathOption(
                                 'PathOption',
                                 path_type=Path,
                                 choices=[Path("."), Path("..")]))
    float_array = ArrayOption('FloatArray',
                              value_option=FloatOption('FloatOption'))
예제 #2
0
 def test_value_option_must_not_be_array_or_dict(self):
     with self.assertRaises(InitializationError):
         c = MyConfig.get_instance()
         c.array_option = self.OPTION_TYPE('ArrayOption2',
                                           value_option=ArrayOption('test'))
     with self.assertRaises(InitializationError):
         c = MyConfig.get_instance()
         c.array_option = self.OPTION_TYPE('ArrayOption2',
                                           value_option=DictOption('test'))
예제 #3
0
 def test_json_serialization_deserialization_keeps_value(self):
     o = ArrayOption('test', value_option=PathOption('_', path_type=Path))
     v = [Path('.'), Path('..')]
     j = o.serialize_json(v)
     self.assertEqual(o.deserialize_json(j), v)
예제 #4
0
 def test_json_deserialization_of_null(self):
     o = ArrayOption('test', value_option=PathOption('_', path_type=Path))
     self.assertEqual(o.deserialize_json('null'), None)
예제 #5
0
 def test_json_serialization_of_None(self):
     o = ArrayOption('test', value_option=PathOption('_', path_type=Path))
     self.assertEqual(o.serialize_json(None), 'null')
예제 #6
0
 def test_choices_cannot_be_empty(self):
     c = MyConfig.get_instance()
     with self.assertRaises(InitializationError):
         c.empty_choices = ArrayOption('EmptyChoices', choices=[])
예제 #7
0
 class Arrays(DummyMemoryConfig):
     test_array = ArrayOption('ArrayOption', env_name='TEST_ARRAY')
예제 #8
0
 class Arrays(DummyMemoryConfig):
     test_array = ArrayOption('TestArray',
                              choices=[[1, 2, 3], [4, 5, 6]],
                              env_name='TEST_ARRAY')