~testing-cabal/ubuntu/hardy/python-testtools/hardy-tweaks

« back to all changes in this revision

Viewing changes to testtools/tests/test_matchers.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-02 21:01:20 UTC
  • mfrom: (16.99.16 upstream)
  • Revision ID: jelmer@samba.org-20110502210120-f7ryvcd6pcjpoijg
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from testtools.matchers import (
15
15
    AfterPreproccessing,
16
16
    Annotate,
 
17
    AnnotatedMismatch,
17
18
    Equals,
18
19
    DocTestMatches,
19
20
    DoesNotEndWith,
30
31
    MatchesSetwise,
31
32
    MatchesStructure,
32
33
    Mismatch,
 
34
    MismatchDecorator,
33
35
    Not,
34
36
    NotEquals,
35
37
    Raises,
166
168
        ("LessThan(12)", LessThan(12)),
167
169
        ]
168
170
 
169
 
    describe_examples = [('4 is >= 4', 4, LessThan(4))]
 
171
    describe_examples = [
 
172
        ('4 is not > 5', 5, LessThan(4)),
 
173
        ('4 is not > 4', 4, LessThan(4)),
 
174
        ]
170
175
 
171
176
 
172
177
def make_error(type, *args, **kwargs):
330
335
    describe_examples = [("1 != 2: foo", 2, Annotate('foo', Equals(1)))]
331
336
 
332
337
 
 
338
class TestAnnotatedMismatch(TestCase):
 
339
 
 
340
    def test_forwards_details(self):
 
341
        x = Mismatch('description', {'foo': 'bar'})
 
342
        annotated = AnnotatedMismatch("annotation", x)
 
343
        self.assertEqual(x.get_details(), annotated.get_details())
 
344
 
 
345
 
333
346
class TestRaisesInterface(TestCase, TestMatchersInterface):
334
347
 
335
348
    matches_matcher = Raises()
660
673
        ]
661
674
 
662
675
 
 
676
class TestMismatchDecorator(TestCase):
 
677
 
 
678
    def test_forwards_description(self):
 
679
        x = Mismatch("description", {'foo': 'bar'})
 
680
        decorated = MismatchDecorator(x)
 
681
        self.assertEqual(x.describe(), decorated.describe())
 
682
 
 
683
    def test_forwards_details(self):
 
684
        x = Mismatch("description", {'foo': 'bar'})
 
685
        decorated = MismatchDecorator(x)
 
686
        self.assertEqual(x.get_details(), decorated.get_details())
 
687
 
 
688
    def test_repr(self):
 
689
        x = Mismatch("description", {'foo': 'bar'})
 
690
        decorated = MismatchDecorator(x)
 
691
        self.assertEqual(
 
692
            '<testtools.matchers.MismatchDecorator(%r)>' % (x,),
 
693
            repr(decorated))
 
694
 
 
695
 
663
696
def test_suite():
664
697
    from unittest import TestLoader
665
698
    return TestLoader().loadTestsFromName(__name__)