def test_not_match_list_of_lists_value(self): expected = MatcherFullOrderInsensitive([[1, 8], [9, 5, 4], [0, 0, 1]], {}, {}) got = [[4, 5, 9], [1, 0, 0], [1, 9]] assert not expected.match(got)
def test_not_match_dict_complicated_struct(self): expected = MatcherFullOrderInsensitive( { 'a': 23, 'b': { 'bb': 22 }, 'c': [1, 2], 'expected': { 'dd': [4, 2, 8, 6], 'ee': { 'eee': 567, 'c': [] } }, 'cc': [5, 4, 3, 2, 1, 0, {}], }, {}, {}) got = [{ 'a': 23, 'b': { 'bb': 22 }, 'c': [2, 1], 'cc': [0, 1, 2, 3, 4, 5, {}], 'expected': { 'dd': [2, 4, 6, 8], 'ee': { 'eee': 567, 'c': [] } } }] assert not expected.match(got)
def test_not_match_complicated_struct_dict_contains(self): expected = MatcherFullOrderInsensitive( { 'a': 23, 'b': { 'bb': 2 }, 'c': [1, 2], 'expected': { 'dd': [4, 6], 'ee': { 'eee': 567 } } }, {}, {}) got = [{ 'a': 23, 'a1': 32, 'b': { 'bb': 2 }, 'c': [2, 1], 'expected': { 'dd': [2, 4, 6, 8], 'ee': { 'eee': 567, 'eeee': 765 } } }, { 'a': [1, 2, 3] }] assert not expected.match(got)
def test_match_with_greedy_matcher(self): expected = MatcherFullOrderInsensitive([{ 'a': MatchedObjInteger(0, 10) }, { 'a': 10 }], {}, {}) got = [{'a': 10}, {'a': 0}] assert expected.match(got)
def test_not_match_dict_with_bool_values(self): expected = MatcherFullOrderInsensitive({ 'a': False, 'b': False }, {}, {}) got = {'a': False, 'b': True} assert not expected.match(got)
def test_match_list_with_dict_with_null_values(self): expected = MatcherFullOrderInsensitive( [1, 2, '1', { 'a': None, 'b': 1 }], {}, {}) got = ['1', 1, 2, {'a': None, 'b': 1}] assert expected.match(got)
def test_list_with_list_of_dicts_subset(self): expected = MatcherFullOrderInsensitive([[{ 'a': 1 }], [{ 'b': 2 }]], {}, {}) got = [[{'b': 2}, {'a': 1}], [{'b': 2}, {'s': 42}]] assert not expected.match(got)
def test_not_match_dict_inner_dict_subset(self): expected = MatcherFullOrderInsensitive({ 'a': { 'bb': 11 }, 'b': 42 }, {}, {}) got = {'a': {'bb': 11}, 'b': 42, 'c': 54} assert not expected.match(got)
def test_match_dict_inner_dict_not_contains(self): expected = MatcherFullOrderInsensitive({ 'a': { 'bb': 111 }, 'b': 42 }, {}, {}) got = [{'a': {'bb': 11}, 'b': 42, 'c': 54}, 1, 2] assert not expected.match(got)
def test_list_basic(self): expected = MatcherFullOrderInsensitive( [1, '2', ['r', 'q'], { 'a': 1, 'b': [1, 2, 3] }], {}, {}) got = [['q', 'r'], 1, { 'b': [3, 1, 2], 'a': 1, }, '2'] assert expected.match(got)
def test_basic(self): expected = MatcherFullOrderInsensitive( { 'a': 1, 'b': [1, 2, { 'a': 1, 'b': [1, 2] }] }, {}, {}) got = {'a': 1, 'b': [2, {'b': [2, 1], 'a': 1}, 1]} assert expected.match(got)
def test_not_match_list_of_dicts_value(self): expected = MatcherFullOrderInsensitive([{ 'a': 1, 'b': '4' }, { 'a': 1 }, { 'qw': 0, '45': 'rt' }], {}, {}) got = [{'qw': 0, '45': 'rt'}, {'a': 1, 'b': 2}, {'a': 1}] assert not expected.match(got)
def test_structure_1_when_not_subset(self): expected = MatcherFullOrderInsensitive( { 'a': { 'b': [{ 'inner_1': 42, 'inner_2': { 'list': [{ 'sub': 1, 'sub_1': [1, 2, 3] }] } }] }, 'sub_1': { 'sub': 34 } }, {}, {}) 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 not expected.match(got)
def test_match_list_with_null_values(self): expected = MatcherFullOrderInsensitive([1, 2, '1', None], {}, {}) got = ['1', 1, 2, None] assert expected.match(got)
def test_match_dict_with_dummy_values(self): expected = MatcherFullOrderInsensitive({'a': 1, 'b': 4}, {}, {}) got = {'a': 1, 'b': 4} assert expected.match(got)
def test_not_match_list_with_two_same_values(self): expected = MatcherFullOrderInsensitive([[1, 2, 3, 8], [1, 2, 3, 8]], {}, {}) got = [[1, 2, 8, 3], [1, 2, 4, 3]] assert not expected.match(got)
def test_match_list_with_hashables_subset(self): expected = MatcherFullOrderInsensitive([1, 2, '1', '2'], {}, {}) got = ['1', 1, 2, '2'] assert expected.match(got)
def test_match_empty_dict(self): expected = MatcherFullOrderInsensitive({}, {}, {}) got = {} assert expected.match(got)
def test_not_match_empty_list(self): expected = MatcherFullOrderInsensitive([], {}, {}) got = [12] assert not expected.match(got)
def test_list_with_empty_inner_list_contains(self): expected = MatcherFullOrderInsensitive([], {}, {}) got = [[]] assert not expected.match(got)
def test_list_with_inner_list_subset(self): expected = MatcherFullOrderInsensitive([[1, 2], [3, 4]], {}, {}) got = [[1, 2], [3, 4], [5, 6]] assert not expected.match(got)
def test_list_with_inner_list_not_contains(self): expected = MatcherFullOrderInsensitive([9], {}, {}) got = [[2, 4, 1], [1], []] assert not expected.match(got)
def test_empty_list_subset(self): expected = MatcherFullOrderInsensitive([], {}, {}) got = [] assert expected.match(got)
def test_list_with_hashables_contains(self): expected = MatcherFullOrderInsensitive([3, 1], {}, {}) got = [[1, 2, 3], [3, 4, 5], [1, 3, 4]] assert not expected.match(got)
def test_match_dict_with_list_with_diff_order(self): expected = MatcherFullOrderInsensitive({'a': [2, 3, 1]}, {}, {}) got = {'a': [1, 2, 3]} assert expected.match(got)
def test_list_with_hashables_not_equal_when_different_len(self): expected = MatcherFullOrderInsensitive([1, 2, '1', '2'], {}, {}) got = ['1', 1, 2, 1, '2'] assert not expected.match(got)
def test_not_match_dict_with_null_values(self): expected = MatcherFullOrderInsensitive({'a': None, 'b': None}, {}, {}) got = {'a': 1, 'b': None} assert not expected.match(got)
def test_list_with_inner_dict_contains(self): expected = MatcherFullOrderInsensitive([{'a': 1}], {}, {}) got = [[{'a': 1, 'b': 2}]] assert not expected.match(got)
def test_list_with_empty_inner_list_subset(self): expected = MatcherFullOrderInsensitive([[]], {}, {}) got = [[]] assert expected.match(got)
def test_convert_int_to_str(self): expected = MatcherFullOrderInsensitive([1, 2, 3], {}, {}) got = ['1', '2', '3'] assert not expected.match(got)