def test_bind(self): self.assertEqual( base_matchers.Bind('foo').match(_FAKE_CONTEXT, 1), matcher.MatchInfo( match.ObjectMatch(1), {'foo': matcher.BoundValue(match.ObjectMatch(1))}))
def testObjectMatch(self): obj = object(), self.assertEqual(match.ObjectMatch(obj), matcher.create_match(_FAKE_CONTEXT.parsed_file, obj))
def test_eq(self, m): self.assertEqual( base_matchers.Bind('a', m).match(_FAKE_CONTEXT, 3), matcher.MatchInfo(match.ObjectMatch(3), {'a': matcher.BoundValue(match.ObjectMatch(3))}))
def test_double_unless_erasure(self): self.assertEqual( base_matchers.Unless( base_matchers.Unless(base_matchers.Bind('foo'))).match( _FAKE_CONTEXT, 1), matcher.MatchInfo(match.ObjectMatch(1)))
def test_empty(self): self.assertEqual(base_matchers.AllOf().match(_FAKE_CONTEXT, 1), matcher.MatchInfo(match.ObjectMatch(1)))
def test_anything(self): self.assertEqual(base_matchers.Anything().match(_FAKE_CONTEXT, 1), matcher.MatchInfo(match.ObjectMatch(1)))
def test_contains(self): items = ['item1', 'item2', 'item3'] m = base_matchers.Contains('item2') expected = matcher.MatchInfo(match.ObjectMatch(items)) self.assertEqual(m.match(_FAKE_CONTEXT, items), expected)