def test_basic(self):
        expected = MatcherContains({'a': 1}, {}, {})
        got = {'a': 1}

        assert expected.match(got)
    def test_not_match_dict_compare_int_with_float(self):
        expected = MatcherContains({'a': 2}, {}, {})
        got = {'a': 2.0, 'c': 1.1}

        assert not expected.match(got)
    def test_match_dict_inner_dict_when_not_subset(self):
        expected = MatcherContains({'a': {'bb': 11}, 'b': 42}, {}, {})

        got = {'a': {'bb': 1}, 'b': 42, 'c': 54}

        assert not expected.match(got)
    def test_not_match_dict_compare_int_with_none(self):
        expected = MatcherContains({'a': 0}, {}, {})
        got = {'a': None}

        assert not expected.match(got)
    def test_not_match_dict_with_float_value(self):
        expected = MatcherContains({'a': 0.1}, {}, {})
        got = {'a': 0.11, 'c': 0.1}

        assert not expected.match(got)
Esempio n. 6
0
    def test_list_with_hashables_subset(self):
        expected = MatcherContains([1, 2, '1', '2'], {}, {})

        got = [1, 2, '1', '2']

        assert expected.match(got)
    def test_match_empty_dict_not_contains(self):
        expected = MatcherContains([{}], {}, {})
        got = [[{}]]

        assert not expected.match(got)
    def test_match_dict_with_bool_values(self):
        expected = MatcherContains({'a': True}, {}, {})
        got = {'a': True, 'b': 'c'}

        assert expected.match(got)
    def test_not_match_dict_compare_int_with_bool(self):
        expected = MatcherContains({'a': 1}, {}, {})
        got = {'a': True, 'b': 'c'}

        assert not expected.match(got)
Esempio n. 10
0
    def test_match_empty_dict(self):
        expected = MatcherContains({}, {}, {})
        got = {}

        assert expected.match(got)
Esempio n. 11
0
    def test_not_match_dict_with_string_values(self):
        expected = MatcherContains({'a': 'c'}, {}, {})
        got = {'a': 'b', 'b': 'c'}

        assert not expected.match(got)
Esempio n. 12
0
    def test_match_dict_with_list_not_contains(self):
        expected = MatcherContains({'a': [1, 2, 9]}, {}, {})

        got = [{'a': [2, 1, 3]}, {'a': [1, 3, 9]}]

        assert not expected.match(got)
Esempio n. 13
0
    def test_match_when_not_subset(self):
        expected = MatcherContains({'a': 2}, {}, {})

        got = {'a': 1, 'b': 2}

        assert not expected.match(got)
Esempio n. 14
0
    def test_match_dict_inner_dict_not_contains(self):
        expected = MatcherContains({'a': {'bb': 111}, 'b': 42}, {}, {})

        got = [{'a': {'bb': 11}, 'b': 42, 'c': 54}, 1, 2]

        assert not expected.match(got)
Esempio n. 15
0
    def test_match_dict_with_list_subset(self):
        expected = MatcherContains([{'b': [1, 3]}], {}, {})

        got = [{'b': [4, 3, 1, 3]}]

        assert expected.match(got)
Esempio n. 16
0
    def test_match_dict_with_none_value(self):
        expected = MatcherContains({'a': None}, {}, {})
        got = {'a': None, 'b': 'c'}

        assert expected.match(got)
Esempio n. 17
0
    def test_match_dict_with_list_when_not_subset(self):
        expected = MatcherContains({'a': [1, 4]}, {}, {})

        got = {'a': [1, 2, 3]}

        assert not expected.match(got)
Esempio n. 18
0
    def test_not_match_dict_compare_none_with_bool(self):
        expected = MatcherContains({'a': None}, {}, {})
        got = {'a': False}

        assert not expected.match(got)
Esempio n. 19
0
    def test_list_with_inner_list_not_contains(self):
        expected = MatcherContains([9], {}, {})

        got = [[2, 4, 1], [1], []]

        assert not expected.match(got)
Esempio n. 20
0
    def test_match_when_not_contains(self):
        expected = MatcherContains({'a': 2}, {}, {})

        got = [{'a': 1}]

        assert not expected.match(got)