コード例 #1
0
ファイル: test_mom_collections.py プロジェクト: RoboTeddy/mom
  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")
コード例 #2
0
ファイル: test_mom_collections.py プロジェクト: RoboTeddy/mom
  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)