Skip to content

Commit e9a1b8f

Browse files
committed
test_shell explicitly
1 parent 2357656 commit e9a1b8f

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

tests/test_cli.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def test_shell(
516516

517517

518518
@pytest.mark.parametrize(
519-
"cli_args,inputs,env,exception, message",
519+
"cli_args,inputs,env,exception,message",
520520
[
521521
(
522522
['shell', '-L{SOCKET_NAME}', '-c', 'print(str(server.socket_name))'],
@@ -548,6 +548,66 @@ def test_shell_no_server(
548548
)
549549

550550

551+
@pytest.mark.parametrize(
552+
"cli_args,inputs,env,message",
553+
[
554+
(
555+
[
556+
'shell_plus',
557+
'-L{SOCKET_NAME}',
558+
],
559+
[],
560+
{},
561+
'(InteractiveConsole)',
562+
),
563+
(
564+
[
565+
'shell_plus',
566+
'-L{SOCKET_NAME}',
567+
],
568+
[],
569+
{'PANE_ID': '{PANE_ID}'},
570+
'(InteractiveConsole)',
571+
),
572+
],
573+
)
574+
def test_shell_plus(
575+
cli_args,
576+
inputs,
577+
env,
578+
message,
579+
tmpdir,
580+
monkeypatch,
581+
server,
582+
session,
583+
):
584+
monkeypatch.setenv('HOME', str(tmpdir))
585+
window_name = 'my_window'
586+
window = session.new_window(window_name=window_name)
587+
window.split_window()
588+
589+
template_ctx = dict(
590+
SOCKET_NAME=server.socket_name,
591+
SOCKET_PATH=server.socket_path,
592+
SESSION_NAME=session.name,
593+
WINDOW_NAME=window_name,
594+
PANE_ID=window.attached_pane.id,
595+
SERVER_SOCKET_NAME=server.socket_name,
596+
)
597+
598+
cli_args[:] = [cli_arg.format(**template_ctx) for cli_arg in cli_args]
599+
for k, v in env.items():
600+
monkeypatch.setenv(k, v.format(**template_ctx))
601+
602+
with tmpdir.as_cwd():
603+
runner = CliRunner()
604+
605+
result = runner.invoke(
606+
cli.cli, cli_args, input=''.join(inputs), catch_exceptions=True
607+
)
608+
assert message.format(**template_ctx) in result.output
609+
610+
551611
@pytest.mark.parametrize(
552612
"cli_args",
553613
[

0 commit comments

Comments
 (0)