Skip to content

Commit 608fce4

Browse files
committed
Test prompts
1 parent 0d4b12b commit 608fce4

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

tests/test_termui.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ def cli(f):
251251
click.echo(f.name)
252252

253253
result = await runner.invoke(cli, input="\n")
254-
assert result.output == f"file [{__file__}]: {__file__}\n"
254+
assert result.output in (
255+
f"file [{__file__}]: {__file__}\n",
256+
f"file [{__file__}]: \n{__file__}\n",
257+
)
255258

256259

257260
def test_secho(runner):

tests/test_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ def test():
127127

128128
result = await runner.invoke(test, input="y\n")
129129
assert not result.exception
130-
assert result.output == "Foo [y/N]: yes!\n"
130+
assert result.output == "Foo [y/N]: y\nyes!\n"
131131

132132
result = await runner.invoke(test, input="\n")
133133
assert not result.exception
134-
assert result.output == "Foo [y/N]: no :(\n"
134+
assert result.output == "Foo [y/N]: \nno :(\n"
135135

136136
result = await runner.invoke(test, input="n\n")
137137
assert not result.exception
138-
assert result.output == "Foo [y/N]: no :(\n"
138+
assert result.output == "Foo [y/N]: n\nno :(\n"
139139

140140
@click.command()
141141
def test_no():
@@ -146,15 +146,15 @@ def test_no():
146146

147147
result = await runner.invoke(test_no, input="y\n")
148148
assert not result.exception
149-
assert result.output == "Foo [Y/n]: yes!\n"
149+
assert result.output == "Foo [Y/n]: y\nyes!\n"
150150

151151
result = await runner.invoke(test_no, input="\n")
152152
assert not result.exception
153-
assert result.output == "Foo [Y/n]: yes!\n"
153+
assert result.output == "Foo [Y/n]: \nyes!\n"
154154

155155
result = await runner.invoke(test_no, input="n\n")
156156
assert not result.exception
157-
assert result.output == "Foo [Y/n]: no :(\n"
157+
assert result.output == "Foo [Y/n]: n\nno :(\n"
158158

159159

160160
@pytest.mark.anyio
@@ -163,7 +163,7 @@ async def test_confirm_repeat(runner):
163163
"cli", params=[click.Option(["--a/--no-a"], default=None, prompt=True)]
164164
)
165165
result = await runner.invoke(cli, input="\ny\n")
166-
assert result.output == "A [y/n]: Error: invalid input\nA [y/n]: "
166+
assert result.output == "A [y/n]: \nError: invalid input\nA [y/n]: y\n"
167167

168168

169169
@pytest.mark.skipif(WIN, reason="Different behavior on windows.")

0 commit comments

Comments
 (0)