Skip to content

Commit

Permalink
Merged pr click-contrib#62: src/click_repl/utils.py
Browse files Browse the repository at this point in the history
	solved failinf test case:   tests/test_repl.py
  • Loading branch information
GhostOps77 committed Feb 2, 2023
1 parent 76cec67 commit 1c608e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/click_repl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _help_internal() -> str:
info_table[target_info[1]].append(mnemonic)

formatter.write_dl( # type: ignore[arg-type]
( # type: ignore[arg-type]
( # type: ignore[arg-type]
", ".join(map(":{0}".format, sorted(mnemonics))),
description,
)
Expand Down Expand Up @@ -363,7 +363,12 @@ def repl(
return

try:
with group.make_context(None, args, parent=group_ctx) as ctx:
# default_map passes the top-level params to the new group to
# support top-level required params that would reject the
# invocation if missing.
with group.make_context(
None, args, parent=group_ctx, default_map=old_ctx.params
) as ctx:
group.invoke(ctx)
ctx.exit()

Expand Down
12 changes: 11 additions & 1 deletion tests/test_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ def bar(foo):

captured_stdout = capfd.readouterr().out

assert captured_stdout.replace("\r\n", "\n") == ''
assert (
captured_stdout.replace("\r\n", "\n")
== """Usage: pytest [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
bar
foo
repl Start an interactive shell.
"""
)


def test_exit_repl_function():
Expand Down

0 comments on commit 1c608e9

Please sign in to comment.