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