|
12 | 12 |
|
13 | 13 | import libtmux |
14 | 14 | from libtmux.common import has_lt_version |
| 15 | +from libtmux.exc import LibTmuxException |
15 | 16 | from tmuxp import cli, config |
16 | 17 | from tmuxp.cli import ( |
17 | 18 | command_ls, |
@@ -509,6 +510,39 @@ def test_shell( |
509 | 510 | assert expected_output.format(**template_ctx) in result.output |
510 | 511 |
|
511 | 512 |
|
| 513 | +@pytest.mark.parametrize( |
| 514 | + "cli_args,inputs,env,exception, message", |
| 515 | + [ |
| 516 | + ( |
| 517 | + ['shell', '-L{SOCKET_NAME}', '-c', 'print(str(server.socket_name))'], |
| 518 | + [], |
| 519 | + {}, |
| 520 | + LibTmuxException, |
| 521 | + r'.*{SOCKET_NAME}\s\(No such file or directory\).*', |
| 522 | + ), |
| 523 | + ], |
| 524 | +) |
| 525 | +def test_shell_no_server( |
| 526 | + cli_args, inputs, env, exception, message, tmpdir, monkeypatch, socket_name |
| 527 | +): |
| 528 | + monkeypatch.setenv('HOME', str(tmpdir)) |
| 529 | + template_ctx = dict( |
| 530 | + SOCKET_NAME=socket_name, |
| 531 | + ) |
| 532 | + |
| 533 | + cli_args[:] = [cli_arg.format(**template_ctx) for cli_arg in cli_args] |
| 534 | + for k, v in env.items(): |
| 535 | + monkeypatch.setenv(k, v.format(**template_ctx)) |
| 536 | + |
| 537 | + with tmpdir.as_cwd(): |
| 538 | + runner = CliRunner() |
| 539 | + |
| 540 | + with pytest.raises(exception, match=message.format(**template_ctx)): |
| 541 | + runner.invoke( |
| 542 | + cli.cli, cli_args, input=''.join(inputs), catch_exceptions=False |
| 543 | + ) |
| 544 | + |
| 545 | + |
512 | 546 | @pytest.mark.parametrize( |
513 | 547 | "cli_args", |
514 | 548 | [ |
|
0 commit comments