def test_simple(self): dot = Dot('foo') self.assertEqual(dot._apply_item(self.data), 'bar')
def test_not_an_object(self): dot = Dot('bah') with self.assertRaises(MatchError) as cm: dot._apply_item([1,2,3]) self.assertEqual(cm.exception.error, 'tried to access field .bah on a non-object')
def test_no_such_key(self): dot = Dot('gah') self.assertIsNone(dot._apply_item({'bar': 3}))
def test_not_an_object(self): dot = Dot('bah') with self.assertRaises(MatchError) as cm: dot._apply_item([1, 2, 3]) self.assertEqual(cm.exception.error, 'tried to access field .bah on a non-object')