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'])
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)
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')
def test_repr(self): d = MultiBunch() assert repr(d) == 'MultiBunch({})' d.name = 'value' self.assertEqual(repr(d), "MultiBunch({'name': 'value'})")
def test_populated_creation(self): d = MultiBunch(name='value') self.assertEqual(d['name'], 'value') d = MultiBunch({'name': 'value'}) self.assertEqual(d['name'], 'value')
def test_empty_creation(self): d = MultiBunch() assert not d