Skip to content

Commit 8d49b9a

Browse files
chore: update test to strip formmating
1 parent 7afa1ab commit 8d49b9a

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tests/test_typer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
import cmd2
8+
from cmd2 import string_utils as su
89
from cmd2 import utils
910

1011
from .conftest import run_cmd
@@ -127,7 +128,7 @@ def test_typer_execution(typer_app: TyperApp, cmd_input: str, expected: list[str
127128

128129
def test_typer_invalid_syntax(typer_app: TyperApp) -> None:
129130
_out, err = run_cmd(typer_app, 'add "')
130-
assert err[0] == 'Invalid syntax: No closing quotation'
131+
assert su.strip_style(err[0]) == 'Invalid syntax: No closing quotation'
131132

132133

133134
def test_typer_with_no_args(typer_app: TyperApp) -> None:
@@ -159,21 +160,23 @@ def test_typer_help_uses_app_stdout(typer_app: TyperApp, capsys: pytest.CaptureF
159160

160161
typer_app.onecmd_plus_hooks('help add')
161162

162-
out = typer_app.stdout.getvalue()
163+
out = su.strip_style(typer_app.stdout.getvalue())
163164
assert 'Usage: add' in out
164165
assert '--b' in out
165166
assert capsys.readouterr().out == ''
166167

167168

168169
def test_typer_help_uses_docstring(typer_app: TyperApp) -> None:
169170
out, _err = run_cmd(typer_app, 'help documented')
170-
assert any('Usage: documented' in line for line in out)
171-
assert any('Documented typer command.' in line for line in out)
171+
plain = [su.strip_style(line) for line in out]
172+
assert any('Usage: documented' in line for line in plain)
173+
assert any('Documented typer command.' in line for line in plain)
172174

173175

174176
def test_typer_help_prog_name(typer_app: TyperApp) -> None:
175177
out, _err = run_cmd(typer_app, 'help add')
176-
usage_line = next(line for line in out if 'Usage: add' in line)
178+
plain = [su.strip_style(line) for line in out]
179+
usage_line = next(line for line in plain if 'Usage: add' in line)
177180
assert usage_line.strip().startswith('Usage: add')
178181

179182

@@ -215,8 +218,9 @@ def test_typer_commandset_binding() -> None:
215218
def test_typer_commandset_help() -> None:
216219
app = TyperApp(command_sets=[TyperCommandSet()])
217220
out, _err = run_cmd(app, 'help scale')
218-
assert any('Usage: scale' in line for line in out)
219-
assert any('--factor' in line for line in out)
221+
plain = [su.strip_style(line) for line in out]
222+
assert any('Usage: scale' in line for line in plain)
223+
assert any('--factor' in line for line in plain)
220224

221225

222226
# ---------------------------------------------------------------------------
@@ -289,8 +293,9 @@ def test_typer_subcommand_invalid(subcmd_app: TyperApp) -> None:
289293
)
290294
def test_typer_subcommand_help(subcmd_app: TyperApp, cmd_input: str, expected_strings: list[str]) -> None:
291295
out, _err = run_cmd(subcmd_app, cmd_input)
296+
plain = [su.strip_style(line) for line in out]
292297
for s in expected_strings:
293-
assert any(s in line for line in out)
298+
assert any(s in line for line in plain)
294299

295300

296301
def test_typer_subcommand_parse_error_stays_in_repl(

0 commit comments

Comments
 (0)