mirror of
https://github.com/Textualize/rich.git
synced 2025-08-03 17:48:25 +00:00
add a test for the new prompt option
This commit is contained in:
parent
895464fee9
commit
8de138ea6a
1 changed files with 19 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
import io
|
||||
|
||||
from rich.console import Console
|
||||
from rich.prompt import Prompt, IntPrompt, Confirm
|
||||
from rich.prompt import Confirm, IntPrompt, Prompt
|
||||
|
||||
|
||||
def test_prompt_str():
|
||||
|
@ -21,6 +21,24 @@ def test_prompt_str():
|
|||
assert output == expected
|
||||
|
||||
|
||||
def test_prompt_str_case_insensitive():
|
||||
INPUT = "egg\nFoO"
|
||||
console = Console(file=io.StringIO())
|
||||
name = Prompt.ask(
|
||||
"what is your name",
|
||||
console=console,
|
||||
choices=["foo", "bar"],
|
||||
default="baz",
|
||||
case_insensitive=True,
|
||||
stream=io.StringIO(INPUT),
|
||||
)
|
||||
assert name == "foo"
|
||||
expected = "what is your name [foo/bar] (baz): Please select one of the available options\nwhat is your name [foo/bar] (baz): "
|
||||
output = console.file.getvalue()
|
||||
print(repr(output))
|
||||
assert output == expected
|
||||
|
||||
|
||||
def test_prompt_str_default():
|
||||
INPUT = ""
|
||||
console = Console(file=io.StringIO())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue