Skip to content

Commit 7637445

Browse files
committed
Added tests for psuccess() and pwarning().
1 parent 8fa8f18 commit 7637445

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_cmd2.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,6 +2823,27 @@ def test_perror_no_style(base_app, capsys) -> None:
28232823
assert err == msg + end
28242824

28252825

2826+
@with_ansi_style(ru.AllowStyle.ALWAYS)
2827+
def test_psuccess(outsim_app) -> None:
2828+
msg = 'testing...'
2829+
end = '\n'
2830+
outsim_app.psuccess(msg)
2831+
2832+
expected = su.stylize(msg + end, style=Cmd2Style.SUCCESS)
2833+
assert outsim_app.stdout.getvalue() == expected
2834+
2835+
2836+
@with_ansi_style(ru.AllowStyle.ALWAYS)
2837+
def test_pwarning(base_app, capsys) -> None:
2838+
msg = 'testing...'
2839+
end = '\n'
2840+
base_app.pwarning(msg)
2841+
2842+
expected = su.stylize(msg + end, style=Cmd2Style.WARNING)
2843+
_out, err = capsys.readouterr()
2844+
assert err == expected
2845+
2846+
28262847
@with_ansi_style(ru.AllowStyle.ALWAYS)
28272848
def test_pexcept_style(base_app, capsys) -> None:
28282849
msg = Exception('testing...')

0 commit comments

Comments
 (0)