コード例 #1
0
 def test_attribute_assignment(self):
     d = MultiBunch()
     
     d.name = 'value'
     assert hasattr(d, 'name')
     self.assertEqual(d['name'], 'value')
     
     d.name = 'value2'
     self.assertEqual(d['name'], ['value', 'value2'])
     
     d.name = 'value3'
     self.assertEqual(d['name'], ['value', 'value2', 'value3'])
コード例 #2
0
 def test_delete(self):
     d = MultiBunch(name='value')
     del d.name
     
     self.assertEqual(repr(d), 'MultiBunch({})')
     
     def error_test():
         del d.foo
     
     self.assertRaises(AttributeError, error_test)
コード例 #3
0
 def test_attribute_read(self):
     d = MultiBunch()
     d.name = 'value'
     self.assertEqual(d.name, 'value')
     self.assertEqual(d.get('name'), 'value')
     
     d.name = 'value2'
     self.assertEqual(d.name, ['value', 'value2'])
     self.assertEqual(d.get('name'), 'value')
コード例 #4
0
 def test_repr(self):
     d = MultiBunch()
     assert repr(d) == 'MultiBunch({})'
     
     d.name = 'value'
     self.assertEqual(repr(d), "MultiBunch({'name': 'value'})")
コード例 #5
0
 def test_populated_creation(self):
     d = MultiBunch(name='value')
     self.assertEqual(d['name'], 'value')
     
     d = MultiBunch({'name': 'value'})
     self.assertEqual(d['name'], 'value')
コード例 #6
0
 def test_empty_creation(self):
     d = MultiBunch()
     assert not d