def test_rough_match(): assert prefix_search({ "hicatty": "math", "cat": "animal" }, "cat") == { "cat": "animal" }
def test_same(): assert prefix_search({ "cat": "cat", "cat": "cat" }, "ca") == { "cat": "cat", "cat": "cat" }
def test_exact_match(): assert prefix_search({ "category": "math", "cat": "animal" }, "cat") == { "category": "math", "cat": "animal" }
def test_empty_prefix(): assert prefix_search({ 'blarg': 'no you', 'blargblarg': 'stfu' }, '') == { 'blarg': 'no you', 'blargblarg': 'stfu' }
def test_exact_match(): assert prefix_search({ 'category': 'math', 'cat': 'animal' }, 'cat') == { 'category': 'math', 'cat': 'animal' }
def test_number_prefix(): assert prefix_search({ '1': 'cents', '2': 'dolars', '3': 'notes' }, '2') == { '2': 'dolars' }
def test_documentation(): assert prefix_search({ "ac": 1, "ba": 2, "ab": 3 }, "a") == { "ac": 1, "ab": 3 }
def test_spaces(): assert prefix_search( { 'no way': 'jose', 'n o': 'ok...', ' nooooo': "ok I'll stop..." }, 'no') == { 'no way': 'jose' }
def test_only_prefix(): assert prefix_search({ 'no': 'way', 'no': 'ok', 'ono': 'ouo' }, 'no') == { 'no': 'way', 'no': 'ok' }
def test_documentation(): assert prefix_search({ 'ac': 1, 'ba': 2, 'ab': 3 }, 'a') == { 'ac': 1, 'ab': 3 }
def test_no_match(): with pytest.raises(KeyError): prefix_search({'student': 'Mich', 'Phone': '0044123442'}, 'Home')
def test_fail_2(): with pytest.raises(KeyError, match=r'Prefix is not in dictionary.'): prefix_search({"key1": 3, "key2": 22, "key3" : 523}, "key26")
def test_exact_match_2(): assert prefix_search({"theme": "dark", "thesis": "none"}, "the") == {"theme": "dark", "thesis": "none"}
def test_number(): assert prefix_search({"ac": 1, "ba": 2, "ab": 3}, "3") == {}
def test_prefix_too_big(): with pytest.raises(KeyError): prefix_search({"ac": 1, "ba": 2, "ab": 3}, "abcd")
def test_no_prefix_found(): assert prefix_search({'hello': 'world', 'hi': 'there'}, 'no') == {}
def test_not_match(): with pytest.raises(KeyError): prefix_search({"category": "math", "cat": "animal"}, "h")
def test_no_dictionary(): assert prefix_search({}, "") == {}
def test_no_match(): assert prefix_search({"category": "math", "cat": "animal"}, "roger") == {}
def test_no_match_misc_prefix(): with pytest.raises(KeyError): prefix_search({"!#%": 1, "^#%$#": 2, "*&^<?": 3}, "yo")
def test_empty(): assert prefix_search({}, 'a') == {}
def test_oneelement(): assert prefix_search({"cat": "dog"}, "c") == {"cat": "dog"}
def test_degits(): assert prefix_search({"5": 1, "6": 2, "56": 3}, "5") == {"5": 1, "56": 3}
def test_no_match_string_prefix(): with pytest.raises(KeyError): prefix_search({"ac": 1, "ba": 2, "ab": 3}, "zzz")
def test_fail(): with pytest.raises(KeyError, match=r'Prefix is not in dictionary.'): prefix_search({"cat": 3, "dog": 22, "lion" : 523}, "giraffe")
def test_misc_prefix_match(): assert prefix_search({"!#%": 1, "^#%$#": 2, "*&^<?": 3, "!^#>?": 4}, "!") == { "!#%": 1, "!^#>?": 4}
def test_documentation_2(): assert prefix_search({"xyzabc": 1, "abxyz": 5, "xyz": 13}, "xyz") == { "xyzabc": 1, "xyz": 13}
def test_no_match_num_prefix(): with pytest.raises(KeyError): prefix_search({"ac": 1, "ba": 2, "ab": 3}, "100")
def test_noresult(): assert prefix_search({"ac": 1, "ba": 2, "ab": 3}, "c") == {}