~lifeless/testtools/haslength

« back to all changes in this revision

Viewing changes to testtools/tests/matchers/test_dict.py

Fix Python 3.3 failures and make tests pass in release tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        ("KeysEqual('foo', 'bar')", KeysEqual('foo', 'bar')),
49
49
        ]
50
50
 
51
 
    describe_examples = [
52
 
        ("['bar', 'foo'] does not match {'baz': 2, 'foo': 0, 'bar': 1}: "
53
 
         "Keys not equal",
54
 
         {'foo': 0, 'bar': 1, 'baz': 2}, KeysEqual('foo', 'bar')),
55
 
        ]
 
51
    describe_examples = []
 
52
 
 
53
    def test_description(self):
 
54
        matchee = {'foo': 0, 'bar': 1, 'baz': 2}
 
55
        mismatch = KeysEqual('foo', 'bar').match(matchee)
 
56
        description = mismatch.describe()
 
57
        self.assertThat(
 
58
            description, Equals(
 
59
                "['bar', 'foo'] does not match %r: Keys not equal"
 
60
                % (matchee,)))
56
61
 
57
62
 
58
63
class TestSubDictOf(TestCase, TestMatchersInterface):
91
96
        ]
92
97
 
93
98
    str_examples = [
94
 
        ("MatchesDict({'foo': %s, 'baz': %s})" % (
95
 
                Equals('bar'), Not(Equals('qux'))),
 
99
        ("MatchesDict({'baz': %s, 'foo': %s})" % (
 
100
                Not(Equals('qux')), Equals('bar')),
96
101
         matches_matcher),
97
102
        ]
98
103
 
144
149
        ]
145
150
 
146
151
    str_examples = [
147
 
        ("ContainsDict({'foo': %s, 'baz': %s})" % (
148
 
                Equals('bar'), Not(Equals('qux'))),
 
152
        ("ContainsDict({'baz': %s, 'foo': %s})" % (
 
153
                Not(Equals('qux')), Equals('bar')),
149
154
         matches_matcher),
150
155
        ]
151
156
 
190
195
        ]
191
196
 
192
197
    str_examples = [
193
 
        ("ContainedByDict({'foo': %s, 'baz': %s})" % (
194
 
                Equals('bar'), Not(Equals('qux'))),
 
198
        ("ContainedByDict({'baz': %s, 'foo': %s})" % (
 
199
                Not(Equals('qux')), Equals('bar')),
195
200
         matches_matcher),
196
201
        ]
197
202