Skip to content

Commit 02cfedd

Browse files
zappolowskitony
authored andcommitted
fix(load): passthru of tmux config_file
f93179d erroneously renamed the argument for `libtmux.server.Server` which is still called `config_file`.
1 parent e9b0717 commit 02cfedd

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/tmuxp/cli/load.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def load_workspace(
254254
workspace_file: StrPath,
255255
socket_name: t.Optional[str] = None,
256256
socket_path: None = None,
257-
tmux_config_file: None = None,
257+
tmux_config_file: t.Optional[str] = None,
258258
new_session_name: t.Optional[str] = None,
259259
colors: t.Optional[int] = None,
260260
detached: bool = False,
@@ -382,7 +382,7 @@ def load_workspace(
382382
t = Server( # create tmux server object
383383
socket_name=socket_name,
384384
socket_path=socket_path,
385-
workspace_file=tmux_config_file,
385+
config_file=tmux_config_file,
386386
colors=colors,
387387
)
388388

tests/fixtures/tmux/tmux.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
display-message "Hello World"

tests/test_cli.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import libtmux
1414
from libtmux.common import has_lt_version
1515
from libtmux.exc import LibTmuxException
16+
from libtmux.server import Server
1617
from libtmux.session import Session
1718
from tmuxp import cli, exc
1819
from tmuxp.cli.import_config import get_teamocil_dir, get_tmuxinator_dir
@@ -35,8 +36,6 @@
3536
if t.TYPE_CHECKING:
3637
import _pytest.capture
3738

38-
from libtmux.server import Server
39-
4039

4140
def test_creates_config_dir_not_exists(tmp_path: pathlib.Path) -> None:
4241
"""cli.startup() creates config dir if not exists."""
@@ -80,6 +79,28 @@ def test_load_workspace(server: "Server", monkeypatch: pytest.MonkeyPatch) -> No
8079
assert session.name == "sample workspace"
8180

8281

82+
def test_load_workspace_passes_tmux_config(
83+
server: "Server", monkeypatch: pytest.MonkeyPatch
84+
) -> None:
85+
# this is an implementation test. Since this testsuite may be ran within
86+
# a tmux session by the developer himself, delete the TMUX variable
87+
# temporarily.
88+
monkeypatch.delenv("TMUX", raising=False)
89+
session_file = FIXTURE_PATH / "workspace/builder" / "two_pane.yaml"
90+
91+
# open it detached
92+
session = load_workspace(
93+
session_file,
94+
socket_name=server.socket_name,
95+
tmux_config_file=FIXTURE_PATH / "tmux" / "tmux.conf",
96+
detached=True,
97+
)
98+
99+
assert isinstance(session, Session)
100+
assert isinstance(session.server, Server)
101+
assert session.server.config_file == FIXTURE_PATH / "tmux" / "tmux.conf"
102+
103+
83104
def test_load_workspace_named_session(
84105
server: "Server", monkeypatch: pytest.MonkeyPatch
85106
) -> None:

0 commit comments

Comments
 (0)