Skip to content

Commit

Permalink
modified: tests/test_repl.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostOps77 committed Mar 18, 2024
1 parent 252852e commit d963901
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions tests/test_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,58 +186,58 @@ def lvl2_command():
)


# def test_internal_commands(capfd):
# @click.group(invoke_without_command=True)
# @click.pass_context
# def cli(ctx):
# if not ctx.invoked_subcommand:
# click_repl.repl(ctx)

# with mock_stdin(":help\n:exit\n"):
# with pytest.raises((SystemExit, click_repl.exceptions.ExitReplException)):
# cli()

# captured_stdout = capfd.readouterr().out.replace("\r\n", "\n")
# assert (
# captured_stdout
# == """REPL help:

# External/System Commands:
# Prefix External/System commands with "!".

# Internal Commands:
# Prefix Internal commands with ":".
# :clear, :cls Clears screen.
# :?, :h, :help Displays general help information.
# :exit, :q, :quit Exits the REPL.

# """
# )


# @click.group(
# cls=click_repl.ReplCli, startup=lambda: print("hi"), cleanup=lambda: print("bye")
# )
# def main():
# print("main group")


# @main.command()
# def cmd1():
# print("hello")


# def test_replcli_class(capfd):
# with pytest.raises(SystemExit):
# with mock_stdin("cmd1\n"):
# main()

# captured_stdout = capfd.readouterr().out.replace("\r\n", "\n")
# assert (
# captured_stdout
# == """main group
# hi
# hello
# bye
# """
# )
def test_internal_commands(capfd):
@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):
if not ctx.invoked_subcommand:
click_repl.repl(ctx)

with mock_stdin(":help\n:exit\n"):
with pytest.raises((SystemExit, click_repl.exceptions.ExitReplException)):
cli()

captured_stdout = capfd.readouterr().out.replace("\r\n", "\n")
assert (
captured_stdout
== """REPL help:
External/System Commands:
Prefix External/System commands with "!".
Internal Commands:
Prefix Internal commands with ":".
:clear, :cls Clears screen.
:?, :h, :help Displays general help information.
:exit, :q, :quit Exits the REPL.
"""
)


@click.group(
cls=click_repl.ReplCli, startup=lambda: print("hi"), cleanup=lambda: print("bye")
)
def main():
print("main group")


@main.command()
def cmd1():
print("hello")


def test_replcli_class(capfd):
with pytest.raises(SystemExit):
with mock_stdin("cmd1\n"):
main()

captured_stdout = capfd.readouterr().out.replace("\r\n", "\n")
assert (
captured_stdout
== """main group
hi
hello
bye
"""
)

0 comments on commit d963901

Please sign in to comment.