예제 #1
0
 def test_load_attr_as_list_of_on_list_mixed_none(self):
     with self.assertRaises(TypeError):
         info = Info({'sub_info_data': [None, {
             'test': 'test'
         }]},
                     preserve_data=True)
         info._load_attr_as_list_of('sub_info_data', Info)
예제 #2
0
 def test_load_attr_on_invalid_name(self):
     info = Info({'1': 1}, preserve_data=True)
     info._load_attr('1')
     self.assertEqual(info['1'], 1)
예제 #3
0
 def test_subscriptable(self):
     info = Info({})
     setattr(info, 'test', 1)
     self.assertEqual(info['test'], 1)
예제 #4
0
 def test_load_attr_on_missing_key(self):
     info = Info({}, preserve_data=True)
     info._load_attr('test')
     self.assertEqual(info.test, None)
예제 #5
0
 def test_load_attr(self):
     info = Info({'test': 'test'}, preserve_data=True)
     info._load_attr('test')
     self.assertEqual(info.test, 'test')
예제 #6
0
 def __init__(self, dictionary, parent=None, **kwargs):
     if self.__validate_parent(parent): self.parent = parent
     Info.__init__(self, dictionary, **kwargs)
예제 #7
0
 def __init__(self, dictionary, parent=None, **kwargs):
     if self.__validate_parent(parent): self.parent = parent
     Info.__init__(self, dictionary, **kwargs)
예제 #8
0
 def test_load_attr_as_list_of_on_list_mixed_none(self):
     with self.assertRaises(TypeError):
         info = Info({'sub_info_data': [None, {'test':'test'}]}, preserve_data=True)
         info._load_attr_as_list_of('sub_info_data', Info)
예제 #9
0
 def test_load_attr_as(self):
     info = Info({'subinfo': {'test':True}}, preserve_data=True)
     info._load_attr_as('subinfo', Info, preserve_data=True)
     info.subinfo._load_attr('test')
     self.assertEqual(info.subinfo.test, True)
예제 #10
0
 def test_load_attr_as_list_of_on_none(self):
     info = Info({'test': None}, preserve_data=True)
     info._load_attr_as_list_of('test', Info)
     self.assertEqual(info.test, [])
예제 #11
0
 def test_load_attr_on_invalid_name(self):
     info = Info({'1': 1}, preserve_data=True)
     info._load_attr('1')
     self.assertEqual(info['1'], 1)
예제 #12
0
 def test_load_attr_on_missing_key(self):
     info = Info({}, preserve_data=True)
     info._load_attr('test')
     self.assertEqual(info.test, None)
예제 #13
0
 def test_load_attr(self):
     info = Info({'test': 'test'}, preserve_data=True)
     info._load_attr('test')
     self.assertEqual(info.test, 'test')
예제 #14
0
 def test_load_attr_as(self):
     info = Info({'subinfo': {'test': True}}, preserve_data=True)
     info._load_attr_as('subinfo', Info, preserve_data=True)
     info.subinfo._load_attr('test')
     self.assertEqual(info.subinfo.test, True)
예제 #15
0
 def test_load_attr_as_list_of_on_string(self):
     with self.assertRaises(TypeError):
         info = Info({'sub_info_data': 'test'}, preserve_data=True)
         info._load_attr_as_list_of('sub_info_data', Info)
예제 #16
0
 def test_load_attr_as_list_of_on_none(self):
     info = Info({'test': None}, preserve_data=True)
     info._load_attr_as_list_of('test', Info)
     self.assertEqual(info.test, [])
예제 #17
0
 def test_data_deleted_by_default(self):
     info = Info({'test': None})
     with self.assertRaises(AttributeError):
         info._data
예제 #18
0
 def test_load_attr_as_list_of_on_string(self):
     with self.assertRaises(TypeError):
         info = Info({'sub_info_data': 'test'}, preserve_data=True)
         info._load_attr_as_list_of('sub_info_data', Info)
예제 #19
0
 def test_data_not_deleted_with_preserve_data(self):
     info = Info({'test': None}, preserve_data=True)
     self.assertEqual(info._data, {'test': None})
예제 #20
0
 def __init__(self, dictionary, **kwargs):
     Info.__init__(self, dictionary, **kwargs)
예제 #21
0
 def __init__(self, dictionary, **kwargs):
     Info.__init__(self, dictionary, **kwargs)