Esempio n. 1
0
 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))}))
Esempio n. 2
0
 def testObjectMatch(self):
     obj = object(),
     self.assertEqual(match.ObjectMatch(obj),
                      matcher.create_match(_FAKE_CONTEXT.parsed_file, obj))
Esempio n. 3
0
 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))}))
Esempio n. 4
0
 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)))
Esempio n. 5
0
 def test_empty(self):
     self.assertEqual(base_matchers.AllOf().match(_FAKE_CONTEXT, 1),
                      matcher.MatchInfo(match.ObjectMatch(1)))
Esempio n. 6
0
 def test_anything(self):
     self.assertEqual(base_matchers.Anything().match(_FAKE_CONTEXT, 1),
                      matcher.MatchInfo(match.ObjectMatch(1)))
Esempio n. 7
0
 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)