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