Ejemplo n.º 1
0
 def test_description(self):
     matchee = {'foo': 0, 'bar': 1, 'baz': 2}
     mismatch = KeysEqual('foo', 'bar').match(matchee)
     description = mismatch.describe()
     self.assertThat(
         description,
         Equals("['bar', 'foo'] does not match %r: Keys not equal" %
                (matchee, )))
Ejemplo n.º 2
0
 def test_description(self):
     matchee = {'foo': 0, 'bar': 1, 'baz': 2}
     mismatch = KeysEqual('foo', 'bar').match(matchee)
     description = mismatch.describe()
     self.assertThat(
         description, Equals(
             "['bar', 'foo'] does not match %r: Keys not equal"
             % (matchee,)))
Ejemplo n.º 3
0
class TestKeysEqual(TestCase, TestMatchersInterface):

    matches_matcher = KeysEqual('foo', 'bar')
    matches_matches = [
        {
            'foo': 0,
            'bar': 1
        },
    ]
    matches_mismatches = [
        {},
        {
            'foo': 0
        },
        {
            'bar': 1
        },
        {
            'foo': 0,
            'bar': 1,
            'baz': 2
        },
        {
            'a': None,
            'b': None,
            'c': None
        },
    ]

    str_examples = [
        ("KeysEqual('foo', 'bar')", KeysEqual('foo', 'bar')),
    ]

    describe_examples = []

    def test_description(self):
        matchee = {'foo': 0, 'bar': 1, 'baz': 2}
        mismatch = KeysEqual('foo', 'bar').match(matchee)
        description = mismatch.describe()
        self.assertThat(
            description,
            Equals("['bar', 'foo'] does not match %r: Keys not equal" %
                   (matchee, )))
Ejemplo n.º 4
0
class TestKeysEqualEmpty(TestCase, TestMatchersInterface):

    matches_matcher = KeysEqual()
    matches_matches = [
        {},
    ]
    matches_mismatches = [
        {
            'foo': 0,
            'bar': 1
        },
        {
            'foo': 0
        },
        {
            'bar': 1
        },
        {
            'foo': 0,
            'bar': 1,
            'baz': 2
        },
        {
            'a': None,
            'b': None,
            'c': None
        },
    ]

    str_examples = [
        ("KeysEqual()", KeysEqual()),
    ]

    describe_examples = [
        ("[] does not match {1: 2}: Keys not equal", {
            1: 2
        }, matches_matcher),
    ]
Ejemplo n.º 5
0
class TestKeysEqualWithDict(TestKeysEqualWithList):

    matches_matcher = KeysEqual({'foo': 3, 'bar': 4})