def test_structure_1_subset(self): expected = MatcherContains( { 'a': { 'b': [{ 'inner_1': 42, 'inner_2': { 'list': [{ 'sub': 1, 'sub_1': [1, 2] }] } }] } }, {}, {}) got = { 'a': { 'b': [{ 'inner_1': 42, 'inner_2': { 'list': [{ 'sub': 1, 'sub_1': [1, 2], 'sub_2': [1, 2] }] } }] }, 'b': { 'z': 23 }, 'sub_1': [1, 2] } assert expected.match(got)
def test_match_complicated_struct_dict_not_contains(self): expected = MatcherContains( { 'a': 23, 'b': { 'bb': 22 }, 'c': [1, 2], 'expected': { 'dd': [4, 6, 9], 'ee': { 'eee': 567 } } }, {}, {}) got = [{ 'a': 23, 'a1': 32, 'b': { 'bb': 2 }, 'c': [2, 1], 'expected': { 'dd': [2, 4, 6, 8], 'ee': { 'eeee': 765 } } }, { 'a': [1, 2, 3] }] assert not expected.match(got)
def test_match_list_with_none_value(self): expected = MatcherContains([None], {}, {}) got = [None, 1, 2] assert expected.match(got)
def test_match_dict_with_none_value(self): expected = MatcherContains({'a': None}, {}, {}) got = {'a': None, 'b': 'c'} assert expected.match(got)
def test_not_match_list_compare_int_with_bool_1(self): expected = MatcherContains([1], {}, {}) got = [True] assert not expected.match(got)
def test_list_with_empty_inner_list_subset(self): expected = MatcherContains([[]], {}, {}) got = [[]] assert expected.match(got)
def test_list_with_list_of_dicts_not_subset(self): expected = MatcherContains([[{'a': 2}], [{'b': 2}]], {}, {}) got = [[{'b': 1}, {'a': 1}], [{'a': 2}, {'b': 2}]] 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_empty_list_subset(self): expected = MatcherContains([], {}, {}) got = [] assert expected.match(got)
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)
def test_not_match_list_compare_float_with_int(self): expected = MatcherContains([1.0], {}, {}) got = [1, 2] assert not expected.match(got)
def test_basic(self): expected = MatcherContains({'a': 1}, {}, {}) got = {'a': 1} assert expected.match(got)
def test_match_dict_with_list_subset(self): expected = MatcherContains([{'b': [1, 3]}], {}, {}) got = [{'b': [4, 3, 1, 3]}] assert 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_float(self): expected = MatcherContains({'a': 2}, {}, {}) got = {'a': 2.0, 'c': 1.1} 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)
def test_not_match_list_compare_none_with_bool(self): expected = MatcherContains([None], {}, {}) got = [False] assert not expected.match(got)
def test_not_match_list_compare_int_with_float(self): expected = MatcherContains([2], {}, {}) got = [2.0, 1] assert not expected.match(got)
def test_not_match_list_compare_none_with_empty_dict(self): expected = MatcherContains([None], {}, {}) got = [{}] assert not expected.match(got)
def test_not_match_dict_compare_none_with_bool(self): expected = MatcherContains({'a': None}, {}, {}) got = {'a': False} assert not expected.match(got)
def test_list_with_hashables_not_equal_when_different_len(self): expected = MatcherContains([1, 2, '1', '2'], {}, {}) got = ['1', 1, 2, 1, 3] assert not expected.match(got)
def test_list_with_inner_list_not_contains(self): expected = MatcherContains([9], {}, {}) got = [[2, 4, 1], [1], []] assert not expected.match(got)
def test_convert_int_to_str(self): expected = MatcherContains([1, 2], {}, {}) got = [1, 2, 3] assert expected.match(got)
def test_not_match_list_with_str_value(self): expected = MatcherContains(['a'], {}, {}) got = ['aa', 'b', 'c'] assert not expected.match(got)
def test_list_with_inner_list_not_subset(self): expected = MatcherContains([[1, 2], [3, 8]], {}, {}) got = [[1, 2], [3, 4], [5, 6]] assert not expected.match(got)
def test_list_with_hashables_not_subset(self): expected = MatcherContains([1, 2, '1', '2'], {}, {}) got = ['1', 1, 2, 3] assert not expected.match(got)
def test_list_with_inner_dict_not_subset(self): expected = MatcherContains([{'a': 2}], {}, {}) got = [{'a': 1, 'b': 2}] assert not expected.match(got)
def test_not_match_list_with_bool_value(self): expected = MatcherContains([False], {}, {}) got = [True, True] assert not expected.match(got)
def test_list_with_hashables_not_contains(self): expected = MatcherContains([4, 1], {}, {}) got = [[1, 2, 3], [3, 4, 5], [1, 3]] assert not expected.match(got)
def test_not_match_list_compare_bool_with_int_1(self): expected = MatcherContains([False], {}, {}) got = [0] assert not expected.match(got)