Esempio n. 1
0
  def test_behavior(self):
    d = AttributeDict(something="foobar", another_thing="haha")
    self.assertEqual(d.something, "foobar")
    self.assertEqual(d.another_thing, "haha")

    d = attrdict(something="foobar", another_thing="haha")
    self.assertEqual(d.something, "foobar")
    self.assertEqual(d.another_thing, "haha")
Esempio n. 2
0
  def test_AttributeError_when_key_not_found(self):
    d = AttributeDict(something="foobar", another_thing="haha")
    a = attrdict(something="foobar", another_thing="haha")

    def foo_wrapper(d):
      return d.not_present

    self.assertRaises(AttributeError, foo_wrapper, d)
    self.assertRaises(AttributeError, foo_wrapper, a)