~testing-cabal/testtools/trunk

« back to all changes in this revision

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

  • Committer: Free Ekanayaka
  • Author(s): Gavin Panella
  • Date: 2017-03-17 18:29:29 UTC
  • Revision ID: git-v1:bb7c7ecfc6ede7160856513db7160f52df40be14
Make KeysEqual usable with no arguments, i.e. match a dict with no keys. (#241)

Make KeysEqual usable with no arguments, i.e. match a dict with no keys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        ]
31
31
 
32
32
 
 
33
class TestKeysEqualEmpty(TestCase, TestMatchersInterface):
 
34
 
 
35
    matches_matcher = KeysEqual()
 
36
    matches_matches = [
 
37
        {},
 
38
        ]
 
39
    matches_mismatches = [
 
40
        {'foo': 0, 'bar': 1},
 
41
        {'foo': 0},
 
42
        {'bar': 1},
 
43
        {'foo': 0, 'bar': 1, 'baz': 2},
 
44
        {'a': None, 'b': None, 'c': None},
 
45
        ]
 
46
 
 
47
    str_examples = [
 
48
        ("KeysEqual()", KeysEqual()),
 
49
        ]
 
50
 
 
51
    describe_examples = [
 
52
        ("[] does not match {1: 2}: Keys not equal",
 
53
         {1: 2}, matches_matcher),
 
54
        ]
 
55
 
 
56
 
33
57
class TestKeysEqualWithList(TestCase, TestMatchersInterface):
34
58
 
35
59
    matches_matcher = KeysEqual('foo', 'bar')