Skip to content

Commit ffa2186

Browse files
authored
build(deps): libtmux 0.14 -> 0.15 (#805)
libtmux moved source to src/, has doctest coverage in its markdown via gp-libs, and now has a pytest plugin.
2 parents 7eb96e7 + c64bb43 commit ffa2186

File tree

5 files changed

+50
-99
lines changed

5 files changed

+50
-99
lines changed

Diff for: poetry.lock

+37-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ tmuxp = 'tmuxp:cli.cli'
4848
python = "^3.7"
4949
click = "~8"
5050
kaptan = ">=0.5.10"
51-
libtmux = "~0.14.0"
51+
libtmux = "~0.15.0"
5252
colorama = ">=0.3.9"
5353

5454
[tool.poetry.dev-dependencies]

Diff for: tmuxp/cli/debug_info.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os
22
import pathlib
33
import platform
4+
import shutil
45
import sys
56

67
import click
78

89
from libtmux import __version__ as libtmux_version
9-
from libtmux.common import get_version, tmux_cmd, which
10+
from libtmux.common import get_version, tmux_cmd
1011

1112
from ..__about__ import __version__
1213
from .utils import tmuxp_echo
@@ -62,7 +63,7 @@ def format_tmux_resp(std_resp):
6263
"tmux version: %s" % get_version(),
6364
"libtmux version: %s" % libtmux_version,
6465
"tmuxp version: %s" % __version__,
65-
"tmux path: %s" % which("tmux"),
66+
"tmux path: %s" % shutil.which("tmux"),
6667
"tmuxp path: %s" % tmuxp_path,
6768
"shell: %s" % os.environ["SHELL"],
6869
output_break(),

Diff for: tmuxp/cli/load.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import logging
99
import os
1010
import pathlib
11+
import shutil
1112
import sys
1213
from typing import List
1314

1415
import click
1516
import kaptan
1617

17-
from libtmux.common import has_gte_version, which
18+
from libtmux.common import has_gte_version
1819
from libtmux.server import Server
1920

2021
from .. import config, exc, log, util
@@ -357,7 +358,7 @@ def load_workspace(
357358
colors=colors,
358359
)
359360

360-
which("tmux") # raise exception if tmux not found
361+
shutil.which("tmux") # raise exception if tmux not found
361362

362363
try: # load WorkspaceBuilder object for tmuxp config / tmux server
363364
builder = WorkspaceBuilder(

Diff for: tmuxp/conftest.py

+6-87
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import getpass
21
import logging
32
import os
43
import pathlib
4+
import shutil
55
import typing as t
66

77
import pytest
88

99
from _pytest.doctest import DoctestItem
10-
from _pytest.fixtures import SubRequest
1110

12-
from libtmux import exc
13-
from libtmux.common import which
14-
from libtmux.server import Server
15-
from libtmux.test import TEST_SESSION_PREFIX, get_test_session_name, namer
11+
from libtmux.test import namer
1612
from tests.fixtures import utils as test_utils
1713

1814
if t.TYPE_CHECKING:
@@ -22,18 +18,6 @@
2218
USING_ZSH = "zsh" in os.getenv("SHELL", "")
2319

2420

25-
@pytest.fixture(autouse=True, scope="session")
26-
def home_path(tmp_path_factory: pytest.TempPathFactory):
27-
return tmp_path_factory.mktemp("home")
28-
29-
30-
@pytest.fixture(autouse=True, scope="session")
31-
def user_path(home_path: pathlib.Path):
32-
p = home_path / getpass.getuser()
33-
p.mkdir()
34-
return p
35-
36-
3721
@pytest.mark.skipif(USING_ZSH, reason="Using ZSH")
3822
@pytest.fixture(autouse=USING_ZSH, scope="session")
3923
def zshrc(user_path: pathlib.Path):
@@ -47,8 +31,8 @@ def zshrc(user_path: pathlib.Path):
4731

4832

4933
@pytest.fixture(autouse=True)
50-
def home_path_default(user_path: pathlib.Path):
51-
os.environ["HOME"] = str(user_path)
34+
def home_path_default(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path) -> None:
35+
monkeypatch.setenv("HOME", str(user_path))
5236

5337

5438
@pytest.fixture(scope="function")
@@ -70,77 +54,12 @@ def socket_name(request) -> str:
7054
return "tmuxp_test%s" % next(namer)
7155

7256

73-
@pytest.fixture(scope="function")
74-
def server(
75-
request: SubRequest, monkeypatch: pytest.MonkeyPatch, socket_name: str
76-
) -> Server:
77-
tmux = Server(socket_name=socket_name)
78-
79-
def fin() -> None:
80-
tmux.kill_server()
81-
82-
request.addfinalizer(fin)
83-
84-
return tmux
85-
86-
87-
@pytest.fixture(scope="function")
88-
def session(server):
89-
session_name = "tmuxp"
90-
91-
if not server.has_session(session_name):
92-
server.cmd(
93-
"-f",
94-
"/dev/null", # use a blank config to reduce side effects
95-
"new-session",
96-
"-d", # detached
97-
"-s",
98-
session_name,
99-
"/bin/sh", # use /bin/sh as a shell to reduce side effects
100-
# normally, it'd be -c, but new-session is special
101-
)
102-
103-
# find current sessions prefixed with tmuxp
104-
old_test_sessions = [
105-
s.get("session_name")
106-
for s in server._sessions
107-
if s.get("session_name").startswith(TEST_SESSION_PREFIX)
108-
]
109-
110-
TEST_SESSION_NAME = get_test_session_name(server=server)
111-
112-
try:
113-
session = server.new_session(session_name=TEST_SESSION_NAME)
114-
except exc.LibTmuxException as e:
115-
raise e
116-
117-
"""
118-
Make sure that tmuxp can :ref:`test_builder_visually` and switches to
119-
the newly created session for that testcase.
120-
"""
121-
session_id = session.get("session_id")
122-
assert session_id is not None
123-
try:
124-
server.switch_client(target_session=session_id)
125-
except exc.LibTmuxException:
126-
# server.attach_session(session.get('session_id'))
127-
pass
128-
129-
for old_test_session in old_test_sessions:
130-
logger.debug("Old test test session %s found. Killing it." % old_test_session)
131-
server.kill_session(old_test_session)
132-
assert TEST_SESSION_NAME == session.get("session_name")
133-
assert TEST_SESSION_NAME != "tmuxp"
134-
135-
return session
136-
137-
13857
@pytest.fixture(autouse=True)
13958
def add_doctest_fixtures(
140-
request: SubRequest,
59+
request: pytest.FixtureRequest,
14160
doctest_namespace: t.Dict[str, t.Any],
14261
) -> None:
143-
if isinstance(request._pyfuncitem, DoctestItem) and which("tmux"):
62+
if isinstance(request._pyfuncitem, DoctestItem) and shutil.which("tmux"):
14463
doctest_namespace["server"] = request.getfixturevalue("server")
14564
session: "Session" = request.getfixturevalue("session")
14665
doctest_namespace["session"] = session

0 commit comments

Comments
 (0)