File: test_suggestions.py

package info (click to toggle)
textual 2.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,084 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (35 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest

from textual.suggestions import get_suggestion, get_suggestions


@pytest.mark.parametrize(
    "word, possible_words, expected_result",
    (
        ["background", ("background",), "background"],
        ["backgroundu", ("background",), "background"],
        ["bkgrund", ("background",), "background"],
        ["llow", ("background",), None],
        ["llow", ("background", "yellow"), "yellow"],
        ["yllow", ("background", "yellow", "ellow"), "yellow"],
    ),
)
def test_get_suggestion(word, possible_words, expected_result):
    assert get_suggestion(word, possible_words) == expected_result


@pytest.mark.parametrize(
    "word, possible_words, count, expected_result",
    (
        ["background", ("background",), 1, ["background"]],
        ["backgroundu", ("background",), 1, ["background"]],
        ["bkgrund", ("background",), 1, ["background"]],
        ["llow", ("background",), 1, []],
        ["llow", ("background", "yellow"), 1, ["yellow"]],
        ["yllow", ("background", "yellow", "ellow"), 1, ["yellow"]],
        ["yllow", ("background", "yellow", "ellow"), 2, ["yellow", "ellow"]],
        ["yllow", ("background", "yellow", "red"), 2, ["yellow"]],
    ),
)
def test_get_suggestions(word, possible_words, count, expected_result):
    assert get_suggestions(word, possible_words, count) == expected_result