8000 :white_check_mark: Add test for tmuxp freeze by tony · Pull Request #494 · tmux-python/tmuxp · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,55 @@ def test_import_tmuxinator(cli_args, inputs, tmpdir, monkeypatch):
assert tmpdir.join('la.yaml').check()


@pytest.mark.parametrize(
"cli_args,inputs",
[
(['freeze', 'mysession'], ['\n', 'y\n', './la.yaml\n', './la.yaml\n', 'y\n']),
( # Exists
['freeze', 'mysession'],
[
'\n',
'y\n',
'./exists.yaml\n',
'./exists.yaml\n',
'./la.yaml\n',
'./la.yaml\n',
'y\n',
],
),
( # Imply current session if not entered
['freeze'],
['\n', 'y\n', './la.yaml\n', './la.yaml\n', 'y\n'],
),
(
['freeze'],
[
'\n',
'y\n',
'./exists.yaml\n',
'./exists.yaml\n',
'./la.yaml\n',
'./la.yaml\n',
'y\n',
],
), # Exists
],
)
def test_freeze(server, cli_args, inputs, tmpdir, monkeypatch):
monkeypatch.setenv('HOME', str(tmpdir))
tmpdir.join('exists.yaml').ensure()

server.new_session(session_name='mysession')

with tmpdir.as_cwd():
runner = CliRunner()
# Use tmux server (socket name) used in the test
cli_args = cli_args + ['-L', server.socket_name]
Copy link
Member Author
@tony tony Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kstilwell

server is a pytest fixture for a randomly generated tmux session. In order to prevent it clobbering from any of the developer's sessions, it's ran on a custom socket name (via -L socket-name).

Off topic 1: technically it's also possible tmuxp tests could be run in parallel: tmuxp / libtmux respects socket name and socket path

Off topic 2: I created an issue at #495 to streamline freeze a bit more (not require entering the filename a second time)

out = runner.invoke(cli.cli, cli_args, input=''.join(inputs))
print(out.output)
assert tmpdir.join('la.yaml').check()


def test_get_abs_path(tmpdir):
expect = str(tmpdir)
with tmpdir.as_cwd():
Expand Down
0