From c7cc090445aa8871d103405cb5050112a6a478de Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 05:34:42 -0500 Subject: [PATCH 01/12] docs: Fix mention of non-existant type --- src/libtmux/_internal/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtmux/_internal/types.py b/src/libtmux/_internal/types.py index 7e9953dfe..d23bfa474 100644 --- a/src/libtmux/_internal/types.py +++ b/src/libtmux/_internal/types.py @@ -2,7 +2,7 @@ Notes ----- -:class:`StrPath` and :class:`StrOrBytesPath` is based on `typeshed's`_. +:class:`StrPath` is based on `typeshed's`_. .. _typeshed's: https://github.com/python/typeshed/blob/5ff32f3/stdlib/_typeshed/__init__.pyi#L176-L179 """ # E501 From a3c031647888eb93d976e2ee85afd6a39a8d693f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 05:35:32 -0500 Subject: [PATCH 02/12] Session.new_window: Fix `start_directory` check --- src/libtmux/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtmux/session.py b/src/libtmux/session.py index 1016d423c..634f14798 100644 --- a/src/libtmux/session.py +++ b/src/libtmux/session.py @@ -679,7 +679,7 @@ def new_window( window_args += ("-P",) # Catch empty string and default (`None`) - if start_directory and isinstance(start_directory, str): + if start_directory: # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c. start_directory = pathlib.Path(start_directory).expanduser() window_args += (f"-c{start_directory}",) From 7998363d793f3e1d7dae4eecc9bc4e251f679527 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:30:27 -0500 Subject: [PATCH 03/12] Server(feat[new_session]): Add StrPath type support for start_directory why: Standardize path handling to accept both str and PathLike objects what: - Import StrPath from libtmux._internal.types - Update start_directory parameter type annotation to StrPath | None - Update docstring to reflect str or PathLike support - Maintain existing if start_directory: logic for proper command building --- src/libtmux/server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libtmux/server.py b/src/libtmux/server.py index 1eaf82f66..611e9aaeb 100644 --- a/src/libtmux/server.py +++ b/src/libtmux/server.py @@ -15,14 +15,15 @@ import typing as t import warnings +from libtmux import exc, formats from libtmux._internal.query_list import QueryList +from libtmux._internal.types import StrPath from libtmux.common import tmux_cmd from libtmux.neo import fetch_objs from libtmux.pane import Pane from libtmux.session import Session from libtmux.window import Window -from . import exc, formats from .common import ( EnvironmentMixin, PaneDict, @@ -431,7 +432,7 @@ def new_session( session_name: str | None = None, kill_session: bool = False, attach: bool = False, - start_directory: str | None = None, + start_directory: StrPath | None = None, window_name: str | None = None, window_command: str | None = None, x: int | DashLiteral | None = None, @@ -466,7 +467,7 @@ def new_session( kill_session : bool, optional Kill current session if ``$ tmux has-session``. Useful for testing workspaces. - start_directory : str, optional + start_directory : str or PathLike, optional specifies the working directory in which the new session is created. window_name : str, optional @@ -542,7 +543,9 @@ def new_session( tmux_args += ("-d",) if start_directory: - tmux_args += ("-c", start_directory) + # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-session -c. + start_directory = pathlib.Path(start_directory).expanduser() + tmux_args += ("-c", str(start_directory)) if window_name: tmux_args += ("-n", window_name) From 66ccd3fe783cc8a71ad36b60d304299876a324e5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:31:25 -0500 Subject: [PATCH 04/12] Pane(feat[split,split_window]): Add StrPath type support for start_directory why: Standardize path handling to accept both str and PathLike objects what: - Import StrPath from libtmux._internal.types - Update start_directory parameter type annotations to StrPath | None - Update docstrings to reflect str or PathLike support - Fix logic pattern from 'is not None' to truthy check for proper command building - Clean up import organization --- src/libtmux/pane.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libtmux/pane.py b/src/libtmux/pane.py index f16cbe9f7..9578bda0e 100644 --- a/src/libtmux/pane.py +++ b/src/libtmux/pane.py @@ -13,6 +13,8 @@ import typing as t import warnings +from libtmux import exc +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, has_lt_version, tmux_cmd from libtmux.constants import ( PANE_DIRECTION_FLAG_MAP, @@ -23,8 +25,6 @@ from libtmux.formats import FORMAT_SEPARATOR from libtmux.neo import Obj, fetch_obj -from . import exc - if t.TYPE_CHECKING: import sys import types @@ -548,7 +548,7 @@ def split( self, /, target: int | str | None = None, - start_directory: str | None = None, + start_directory: StrPath | None = None, attach: bool = False, direction: PaneDirection | None = None, full_window_split: bool | None = None, @@ -566,7 +566,7 @@ def split( attach : bool, optional make new window the current window after creating it, default True. - start_directory : str, optional + start_directory : str or PathLike, optional specifies the working directory in which the new window is created. direction : PaneDirection, optional split in direction. If none is specified, assume down. @@ -668,7 +668,7 @@ def split( tmux_args += ("-P", "-F{}".format("".join(tmux_formats))) # output - if start_directory is not None: + if start_directory: # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c. start_path = pathlib.Path(start_directory).expanduser() tmux_args += (f"-c{start_path}",) @@ -870,7 +870,7 @@ def split_window( self, target: int | str | None = None, attach: bool = False, - start_directory: str | None = None, + start_directory: StrPath | None = None, vertical: bool = True, shell: str | None = None, size: str | int | None = None, @@ -883,7 +883,7 @@ def split_window( ---------- attach : bool, optional Attach / select pane after creation. - start_directory : str, optional + start_directory : str or PathLike, optional specifies the working directory in which the new pane is created. vertical : bool, optional split vertically From 5305b4a52aea3f6d2bc6bc6531c25e385b0884cf Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:31:51 -0500 Subject: [PATCH 05/12] Window(feat[split,split_window]): Add StrPath type support for start_directory why: Standardize path handling to accept both str and PathLike objects what: - Import StrPath from libtmux._internal.types - Update start_directory parameter type annotations to StrPath | None - Update docstring to reflect str or PathLike support --- src/libtmux/window.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 121c7ea03..1462ce4d8 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -14,6 +14,7 @@ import warnings from libtmux._internal.query_list import QueryList +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, tmux_cmd from libtmux.constants import ( RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP, @@ -258,7 +259,7 @@ def split( self, /, target: int | str | None = None, - start_directory: str | None = None, + start_directory: StrPath | None = None, attach: bool = False, direction: PaneDirection | None = None, full_window_split: bool | None = None, @@ -274,7 +275,7 @@ def split( attach : bool, optional make new window the current window after creating it, default True. - start_directory : str, optional + start_directory : str or PathLike, optional specifies the working directory in which the new window is created. direction : PaneDirection, optional split in direction. If none is specified, assume down. @@ -864,7 +865,7 @@ def width(self) -> str | None: def split_window( self, target: int | str | None = None, - start_directory: str | None = None, + start_directory: StrPath | None = None, attach: bool = False, vertical: bool = True, shell: str | None = None, From 12c35b3ec327c157594e7ea8088a673ab2b71a48 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:47:50 -0500 Subject: [PATCH 06/12] tests(Pane.split) with start_directory parameter what: - Introduced StartDirectoryTestFixture for parameter testing - Added tests for various start_directory scenarios including None, empty string, absolute path, and pathlib.Path - Updated test_pane_context_manager to verify pane count after context exit - Added test for pathlib.Path acceptance in Pane.split --- tests/test_pane.py | 97 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/tests/test_pane.py b/tests/test_pane.py index 746467851..c552db905 100644 --- a/tests/test_pane.py +++ b/tests/test_pane.py @@ -3,11 +3,13 @@ from __future__ import annotations import logging +import pathlib import shutil import typing as t import pytest +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, has_lt_version, has_lte_version from libtmux.constants import PaneDirection, ResizeAdjustmentDirection from libtmux.test.retry import retry_until @@ -327,11 +329,98 @@ def test_split_pane_size(session: Session) -> None: def test_pane_context_manager(session: Session) -> None: """Test Pane context manager functionality.""" window = session.new_window() + initial_pane_count = len(window.panes) + with window.split() as pane: - pane.send_keys('echo "Hello"') + assert len(window.panes) == initial_pane_count + 1 assert pane in window.panes - assert len(window.panes) == 2 # Initial pane + new pane # Pane should be killed after exiting context - assert pane not in window.panes - assert len(window.panes) == 1 # Only initial pane remains + window.refresh() + assert len(window.panes) == initial_pane_count + + +class StartDirectoryTestFixture(t.NamedTuple): + """Test fixture for start_directory parameter testing.""" + + test_id: str + start_directory: StrPath | None + expected_in_cmd: list[str] + expected_not_in_cmd: list[str] + description: str + + +START_DIRECTORY_TEST_FIXTURES: list[StartDirectoryTestFixture] = [ + StartDirectoryTestFixture( + test_id="none_value", + start_directory=None, + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="None should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="empty_string", + start_directory="", + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="Empty string should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="absolute_path_string", + start_directory="/tmp/test", + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="Absolute path string should add -c flag", + ), + StartDirectoryTestFixture( + test_id="pathlib_absolute", + start_directory=pathlib.Path("/tmp/test"), + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="pathlib.Path absolute should add -c flag", + ), +] + + +@pytest.mark.parametrize( + list(StartDirectoryTestFixture._fields), + START_DIRECTORY_TEST_FIXTURES, + ids=[test.test_id for test in START_DIRECTORY_TEST_FIXTURES], +) +def test_split_start_directory( + test_id: str, + start_directory: StrPath | None, + expected_in_cmd: list[str], + expected_not_in_cmd: list[str], + description: str, + session: Session, +) -> None: + """Test Pane.split start_directory parameter handling.""" + window = session.new_window(window_name=f"test_split_{test_id}") + pane = window.active_pane + assert pane is not None + + # Split pane with start_directory parameter + new_pane = pane.split(start_directory=start_directory) + + # Verify pane was created successfully + assert new_pane in window.panes + assert len(window.panes) == 2 + + +def test_split_start_directory_pathlib(session: Session) -> None: + """Test Pane.split accepts pathlib.Path for start_directory.""" + import tempfile + + with tempfile.TemporaryDirectory() as temp_dir: + path_obj = pathlib.Path(temp_dir) + + window = session.new_window(window_name="test_split_pathlib") + pane = window.active_pane + assert pane is not None + + # Should accept pathlib.Path without error + new_pane = pane.split(start_directory=path_obj) + + assert new_pane in window.panes + assert len(window.panes) == 2 From f1b6401109f008d864f6dc2cd402d8476228797c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:48:19 -0500 Subject: [PATCH 07/12] tests(server) Improve `start_directory` tests for `new_session` what: - Added StartDirectoryTestFixture for comprehensive testing of start_directory scenarios - Implemented tests for None, empty string, absolute path, and pathlib.Path inputs - Verified correct command generation based on start_directory values - Ensured compatibility with pathlib.Path in new_session method --- tests/test_server.py | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/test_server.py b/tests/test_server.py index 32060ff24..6c0048de2 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -4,12 +4,14 @@ import logging import os +import pathlib import subprocess import time import typing as t import pytest +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, has_version from libtmux.server import Server @@ -308,3 +310,87 @@ def test_server_context_manager(TestServer: type[Server]) -> None: # Server should be killed after exiting context assert not server.is_alive() + + +class StartDirectoryTestFixture(t.NamedTuple): + """Test fixture for start_directory parameter testing.""" + + test_id: str + start_directory: StrPath | None + expected_in_cmd: list[str] + expected_not_in_cmd: list[str] + description: str + + +START_DIRECTORY_TEST_FIXTURES: list[StartDirectoryTestFixture] = [ + StartDirectoryTestFixture( + test_id="none_value", + start_directory=None, + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="None should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="empty_string", + start_directory="", + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="Empty string should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="absolute_path_string", + start_directory="/tmp/test", + expected_in_cmd=["-c", "/tmp/test"], + expected_not_in_cmd=[], + description="Absolute path string should add -c flag", + ), + StartDirectoryTestFixture( + test_id="pathlib_absolute", + start_directory=pathlib.Path("/tmp/test"), + expected_in_cmd=["-c", "/tmp/test"], + expected_not_in_cmd=[], + description="pathlib.Path absolute should add -c flag", + ), +] + + +@pytest.mark.parametrize( + list(StartDirectoryTestFixture._fields), + START_DIRECTORY_TEST_FIXTURES, + ids=[test.test_id for test in START_DIRECTORY_TEST_FIXTURES], +) +def test_new_session_start_directory( + test_id: str, + start_directory: StrPath | None, + expected_in_cmd: list[str], + expected_not_in_cmd: list[str], + description: str, + server: Server, +) -> None: + """Test Server.new_session start_directory parameter handling.""" + # Create session with start_directory parameter + session = server.new_session( + session_name=f"test_start_dir_{test_id}", + start_directory=start_directory, + ) + + # Verify session was created successfully + assert session.session_name == f"test_start_dir_{test_id}" + assert server.has_session(f"test_start_dir_{test_id}") + + +def test_new_session_start_directory_pathlib(server: Server) -> None: + """Test Server.new_session accepts pathlib.Path for start_directory.""" + import tempfile + + with tempfile.TemporaryDirectory() as temp_dir: + path_obj = pathlib.Path(temp_dir) + + # Should accept pathlib.Path without error + session = server.new_session( + session_name="test_pathlib_start_dir", + start_directory=path_obj, + ) + + assert session.session_name == "test_pathlib_start_dir" + assert server.has_session("test_pathlib_start_dir") From 9202412414517be01b3b9eb153b5429d313b9cda Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:48:32 -0500 Subject: [PATCH 08/12] tests(session) Add `new_window` start_directory tests what: - Added comprehensive tests for `start_directory` parameter handling in `Session.new_window` - Included scenarios for None, empty string, absolute path, and pathlib.Path - Verified correct command generation and window creation based on `start_directory` values - Ensured compatibility with pathlib.Path for start_directory input --- tests/test_session.py | 93 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/tests/test_session.py b/tests/test_session.py index 88d5f79e6..16f0ecbb5 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -3,12 +3,14 @@ from __future__ import annotations import logging +import pathlib import shutil import typing as t import pytest from libtmux import exc +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, has_lt_version from libtmux.constants import WindowDirection from libtmux.pane import Pane @@ -424,9 +426,94 @@ def test_session_context_manager(server: Server) -> None: """Test Session context manager functionality.""" with server.new_session() as session: window = session.new_window() - assert session in server.sessions + assert len(session.windows) >= 2 # Initial window + new window assert window in session.windows - assert len(session.windows) == 2 # Initial window + new window # Session should be killed after exiting context - assert session not in server.sessions + session_name = session.session_name + assert session_name is not None + assert not server.has_session(session_name) + + +class StartDirectoryTestFixture(t.NamedTuple): + """Test fixture for start_directory parameter testing.""" + + test_id: str + start_directory: StrPath | None + expected_in_cmd: list[str] + expected_not_in_cmd: list[str] + description: str + + +START_DIRECTORY_TEST_FIXTURES: list[StartDirectoryTestFixture] = [ + StartDirectoryTestFixture( + test_id="none_value", + start_directory=None, + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="None should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="empty_string", + start_directory="", + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="Empty string should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="absolute_path_string", + start_directory="/tmp/test", + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="Absolute path string should add -c flag", + ), + StartDirectoryTestFixture( + test_id="pathlib_absolute", + start_directory=pathlib.Path("/tmp/test"), + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="pathlib.Path absolute should add -c flag", + ), +] + + +@pytest.mark.parametrize( + list(StartDirectoryTestFixture._fields), + START_DIRECTORY_TEST_FIXTURES, + ids=[test.test_id for test in START_DIRECTORY_TEST_FIXTURES], +) +def test_new_window_start_directory( + test_id: str, + start_directory: StrPath | None, + expected_in_cmd: list[str], + expected_not_in_cmd: list[str], + description: str, + session: Session, +) -> None: + """Test Session.new_window start_directory parameter handling.""" + # Create window with start_directory parameter + window = session.new_window( + window_name=f"test_start_dir_{test_id}", + start_directory=start_directory, + ) + + # Verify window was created successfully + assert window.window_name == f"test_start_dir_{test_id}" + assert window in session.windows + + +def test_new_window_start_directory_pathlib(session: Session) -> None: + """Test Session.new_window accepts pathlib.Path for start_directory.""" + import tempfile + + with tempfile.TemporaryDirectory() as temp_dir: + path_obj = pathlib.Path(temp_dir) + + # Should accept pathlib.Path without error + window = session.new_window( + window_name="test_pathlib_start_dir", + start_directory=path_obj, + ) + + assert window.window_name == "test_pathlib_start_dir" + assert window in session.windows From a6d220cb8c916e7ebd9b95ff65ada34010a51671 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:49:00 -0500 Subject: [PATCH 09/12] tests(window[split]) Add `start_directory` tests what: - Added tests for start_directory parameter handling in Window.split - Included scenarios for None, empty string, absolute path, and pathlib.Path - Verified correct pane creation and command generation based on start_directory values - Ensured compatibility with pathlib.Path for start_directory input --- tests/test_window.py | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/tests/test_window.py b/tests/test_window.py index a61345711..4eb61064e 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +import pathlib import shutil import time import typing as t @@ -11,6 +12,7 @@ from libtmux import exc from libtmux._internal.query_list import ObjectDoesNotExist +from libtmux._internal.types import StrPath from libtmux.common import has_gte_version, has_lt_version, has_lte_version from libtmux.constants import ( PaneDirection, @@ -653,3 +655,85 @@ def test_window_context_manager(session: Session) -> None: # Window should be killed after exiting context assert window not in session.windows + + +class StartDirectoryTestFixture(t.NamedTuple): + """Test fixture for start_directory parameter testing.""" + + test_id: str + start_directory: StrPath | None + expected_in_cmd: list[str] + expected_not_in_cmd: list[str] + description: str + + +START_DIRECTORY_TEST_FIXTURES: list[StartDirectoryTestFixture] = [ + StartDirectoryTestFixture( + test_id="none_value", + start_directory=None, + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="None should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="empty_string", + start_directory="", + expected_in_cmd=[], + expected_not_in_cmd=["-c"], + description="Empty string should not add -c flag", + ), + StartDirectoryTestFixture( + test_id="absolute_path_string", + start_directory="/tmp/test", + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="Absolute path string should add -c flag", + ), + StartDirectoryTestFixture( + test_id="pathlib_absolute", + start_directory=pathlib.Path("/tmp/test"), + expected_in_cmd=["-c"], + expected_not_in_cmd=[], + description="pathlib.Path absolute should add -c flag", + ), +] + + +@pytest.mark.parametrize( + list(StartDirectoryTestFixture._fields), + START_DIRECTORY_TEST_FIXTURES, + ids=[test.test_id for test in START_DIRECTORY_TEST_FIXTURES], +) +def test_split_start_directory( + test_id: str, + start_directory: StrPath | None, + expected_in_cmd: list[str], + expected_not_in_cmd: list[str], + description: str, + session: Session, +) -> None: + """Test Window.split start_directory parameter handling.""" + window = session.new_window(window_name=f"test_window_split_{test_id}") + + # Split window with start_directory parameter + new_pane = window.split(start_directory=start_directory) + + # Verify pane was created successfully + assert new_pane in window.panes + assert len(window.panes) == 2 + + +def test_split_start_directory_pathlib(session: Session) -> None: + """Test Window.split accepts pathlib.Path for start_directory.""" + import tempfile + + with tempfile.TemporaryDirectory() as temp_dir: + path_obj = pathlib.Path(temp_dir) + + window = session.new_window(window_name="test_window_split_pathlib") + + # Should accept pathlib.Path without error + new_pane = window.split(start_directory=path_obj) + + assert new_pane in window.panes + assert len(window.panes) == 2 From 62840ed7c9aa7fca6a85cae88b918a1f763935af Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 06:53:51 -0500 Subject: [PATCH 10/12] docs(CHANGES) Note `start_directory` annotations and tests --- CHANGES | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGES b/CHANGES index aa4328281..6bd349ee6 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,20 @@ $ pip install --user --upgrade --pre libtmux - _Future release notes will be placed here_ +## libtmux 0.46.2 (Unreleased) + +### Development + +- Add `StrPath` type support for `start_directory` parameters (#596, #597, #598): + - `Server.new_session`: Accept PathLike objects for session start directory + - `Session.new_window`: Accept PathLike objects for window start directory + - `Pane.split` and `Pane.split_window`: Accept PathLike objects for pane start directory + - `Window.split` and `Window.split_window`: Accept PathLike objects for pane start directory + - Enables `pathlib.Path` objects alongside strings for all start directory parameters + - Includes comprehensive tests for all parameter types (None, empty string, string paths, PathLike objects) + + Thank you @Data5tream for the initial commit in #596! + ## libtmux 0.46.1 (2025-03-16) _Maintenance only, no bug fixes or new features_ From 905e395169d2752c2f2f05052ccb1c1b28aba941 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 09:20:25 -0500 Subject: [PATCH 11/12] tests(start_directory) Improve across multiple test files what: - Removed expected_in_cmd and expected_not_in_cmd from StartDirectoryTestFixture. - Updated test cases to handle user_path and relative_path scenarios. - Enhanced logic for formatting start_directory with actual paths in tests. - Ensured compatibility with pathlib.Path for start_directory input across tests in test_pane.py, test_server.py, test_session.py, and test_window.py. --- tests/test_pane.py | 82 ++++++++++++++++++++++--------------- tests/test_server.py | 94 ++++++++++++++++++++++++++----------------- tests/test_session.py | 90 +++++++++++++++++++++++++---------------- tests/test_window.py | 78 +++++++++++++++++++++-------------- 4 files changed, 208 insertions(+), 136 deletions(-) diff --git a/tests/test_pane.py b/tests/test_pane.py index c552db905..7133c85d1 100644 --- a/tests/test_pane.py +++ b/tests/test_pane.py @@ -345,8 +345,6 @@ class StartDirectoryTestFixture(t.NamedTuple): test_id: str start_directory: StrPath | None - expected_in_cmd: list[str] - expected_not_in_cmd: list[str] description: str @@ -354,30 +352,22 @@ class StartDirectoryTestFixture(t.NamedTuple): StartDirectoryTestFixture( test_id="none_value", start_directory=None, - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="None should not add -c flag", ), StartDirectoryTestFixture( test_id="empty_string", start_directory="", - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="Empty string should not add -c flag", ), StartDirectoryTestFixture( - test_id="absolute_path_string", - start_directory="/tmp/test", - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="Absolute path string should add -c flag", + test_id="user_path", + start_directory="{user_path}", + description="User path should add -c flag", ), StartDirectoryTestFixture( - test_id="pathlib_absolute", - start_directory=pathlib.Path("/tmp/test"), - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="pathlib.Path absolute should add -c flag", + test_id="relative_path", + start_directory="./relative/path", + description="Relative path should add -c flag", ), ] @@ -390,37 +380,63 @@ class StartDirectoryTestFixture(t.NamedTuple): def test_split_start_directory( test_id: str, start_directory: StrPath | None, - expected_in_cmd: list[str], - expected_not_in_cmd: list[str], description: str, session: Session, + tmp_path: pathlib.Path, + user_path: pathlib.Path, ) -> None: """Test Pane.split start_directory parameter handling.""" window = session.new_window(window_name=f"test_split_{test_id}") pane = window.active_pane assert pane is not None - # Split pane with start_directory parameter - new_pane = pane.split(start_directory=start_directory) + # Format path placeholders with actual fixture values + actual_start_directory = start_directory + expected_path = None + + if start_directory and str(start_directory) not in ["", "None"]: + if "{user_path}" in str(start_directory): + # Replace placeholder with actual user_path + actual_start_directory = str(start_directory).format(user_path=user_path) + expected_path = str(user_path) + elif str(start_directory).startswith("./"): + # For relative paths, use tmp_path as base + temp_dir = tmp_path / "relative" / "path" + temp_dir.mkdir(parents=True, exist_ok=True) + actual_start_directory = str(temp_dir) + expected_path = str(temp_dir.resolve()) + + # Should not raise an error + new_pane = pane.split(start_directory=actual_start_directory) - # Verify pane was created successfully assert new_pane in window.panes assert len(window.panes) == 2 + # Verify working directory if we have an expected path + if expected_path: + new_pane.refresh() + if new_pane.pane_current_path: + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + assert actual_path == expected_path -def test_split_start_directory_pathlib(session: Session) -> None: - """Test Pane.split accepts pathlib.Path for start_directory.""" - import tempfile - with tempfile.TemporaryDirectory() as temp_dir: - path_obj = pathlib.Path(temp_dir) +def test_split_start_directory_pathlib( + session: Session, user_path: pathlib.Path +) -> None: + """Test Pane.split accepts pathlib.Path for start_directory.""" + window = session.new_window(window_name="test_split_pathlib") + pane = window.active_pane + assert pane is not None - window = session.new_window(window_name="test_split_pathlib") - pane = window.active_pane - assert pane is not None + # Pass pathlib.Path directly to test pathlib.Path acceptance + new_pane = pane.split(start_directory=user_path) - # Should accept pathlib.Path without error - new_pane = pane.split(start_directory=path_obj) + assert new_pane in window.panes + assert len(window.panes) == 2 - assert new_pane in window.panes - assert len(window.panes) == 2 + # Verify working directory + new_pane.refresh() + if new_pane.pane_current_path: + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_server.py b/tests/test_server.py index 6c0048de2..6a94604ea 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -317,8 +317,6 @@ class StartDirectoryTestFixture(t.NamedTuple): test_id: str start_directory: StrPath | None - expected_in_cmd: list[str] - expected_not_in_cmd: list[str] description: str @@ -326,30 +324,22 @@ class StartDirectoryTestFixture(t.NamedTuple): StartDirectoryTestFixture( test_id="none_value", start_directory=None, - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="None should not add -c flag", ), StartDirectoryTestFixture( test_id="empty_string", start_directory="", - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="Empty string should not add -c flag", ), StartDirectoryTestFixture( - test_id="absolute_path_string", - start_directory="/tmp/test", - expected_in_cmd=["-c", "/tmp/test"], - expected_not_in_cmd=[], - description="Absolute path string should add -c flag", + test_id="user_path", + start_directory="{user_path}", + description="User path should add -c flag", ), StartDirectoryTestFixture( - test_id="pathlib_absolute", - start_directory=pathlib.Path("/tmp/test"), - expected_in_cmd=["-c", "/tmp/test"], - expected_not_in_cmd=[], - description="pathlib.Path absolute should add -c flag", + test_id="relative_path", + start_directory="./relative/path", + description="Relative path should add -c flag", ), ] @@ -362,35 +352,65 @@ class StartDirectoryTestFixture(t.NamedTuple): def test_new_session_start_directory( test_id: str, start_directory: StrPath | None, - expected_in_cmd: list[str], - expected_not_in_cmd: list[str], description: str, server: Server, + tmp_path: pathlib.Path, + user_path: pathlib.Path, ) -> None: """Test Server.new_session start_directory parameter handling.""" - # Create session with start_directory parameter + # Format path placeholders with actual fixture values + actual_start_directory = start_directory + expected_path = None + + if start_directory and str(start_directory) not in ["", "None"]: + if "{user_path}" in str(start_directory): + # Replace placeholder with actual user_path + actual_start_directory = str(start_directory).format(user_path=user_path) + expected_path = str(user_path) + elif str(start_directory).startswith("./"): + # For relative paths, use tmp_path as base + temp_dir = tmp_path / "relative" / "path" + temp_dir.mkdir(parents=True, exist_ok=True) + actual_start_directory = str(temp_dir) + expected_path = str(temp_dir.resolve()) + + # Should not raise an error session = server.new_session( - session_name=f"test_start_dir_{test_id}", - start_directory=start_directory, + session_name=f"test_session_{test_id}", + start_directory=actual_start_directory, ) - # Verify session was created successfully - assert session.session_name == f"test_start_dir_{test_id}" - assert server.has_session(f"test_start_dir_{test_id}") + assert session.session_name == f"test_session_{test_id}" + assert server.has_session(f"test_session_{test_id}") + # Verify working directory if we have an expected path + if expected_path: + active_pane = session.active_window.active_pane + assert active_pane is not None + active_pane.refresh() + if active_pane.pane_current_path: + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + assert actual_path == expected_path -def test_new_session_start_directory_pathlib(server: Server) -> None: - """Test Server.new_session accepts pathlib.Path for start_directory.""" - import tempfile - - with tempfile.TemporaryDirectory() as temp_dir: - path_obj = pathlib.Path(temp_dir) - # Should accept pathlib.Path without error - session = server.new_session( - session_name="test_pathlib_start_dir", - start_directory=path_obj, - ) +def test_new_session_start_directory_pathlib( + server: Server, user_path: pathlib.Path +) -> None: + """Test Server.new_session accepts pathlib.Path for start_directory.""" + # Pass pathlib.Path directly to test pathlib.Path acceptance + session = server.new_session( + session_name="test_pathlib_start_dir", + start_directory=user_path, + ) - assert session.session_name == "test_pathlib_start_dir" - assert server.has_session("test_pathlib_start_dir") + assert session.session_name == "test_pathlib_start_dir" + assert server.has_session("test_pathlib_start_dir") + + # Verify working directory + active_pane = session.active_window.active_pane + assert active_pane is not None + active_pane.refresh() + if active_pane.pane_current_path: + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_session.py b/tests/test_session.py index 16f0ecbb5..f52112091 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -440,8 +440,6 @@ class StartDirectoryTestFixture(t.NamedTuple): test_id: str start_directory: StrPath | None - expected_in_cmd: list[str] - expected_not_in_cmd: list[str] description: str @@ -449,30 +447,22 @@ class StartDirectoryTestFixture(t.NamedTuple): StartDirectoryTestFixture( test_id="none_value", start_directory=None, - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="None should not add -c flag", ), StartDirectoryTestFixture( test_id="empty_string", start_directory="", - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="Empty string should not add -c flag", ), StartDirectoryTestFixture( - test_id="absolute_path_string", - start_directory="/tmp/test", - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="Absolute path string should add -c flag", + test_id="user_path", + start_directory="{user_path}", + description="User path should add -c flag", ), StartDirectoryTestFixture( - test_id="pathlib_absolute", - start_directory=pathlib.Path("/tmp/test"), - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="pathlib.Path absolute should add -c flag", + test_id="relative_path", + start_directory="./relative/path", + description="Relative path should add -c flag", ), ] @@ -485,35 +475,65 @@ class StartDirectoryTestFixture(t.NamedTuple): def test_new_window_start_directory( test_id: str, start_directory: StrPath | None, - expected_in_cmd: list[str], - expected_not_in_cmd: list[str], description: str, session: Session, + tmp_path: pathlib.Path, + user_path: pathlib.Path, ) -> None: """Test Session.new_window start_directory parameter handling.""" - # Create window with start_directory parameter + # Format path placeholders with actual fixture values + actual_start_directory = start_directory + expected_path = None + + if start_directory and str(start_directory) not in ["", "None"]: + if "{user_path}" in str(start_directory): + # Replace placeholder with actual user_path + actual_start_directory = str(start_directory).format(user_path=user_path) + expected_path = str(user_path) + elif str(start_directory).startswith("./"): + # For relative paths, use tmp_path as base + temp_dir = tmp_path / "relative" / "path" + temp_dir.mkdir(parents=True, exist_ok=True) + actual_start_directory = str(temp_dir) + expected_path = str(temp_dir.resolve()) + + # Should not raise an error window = session.new_window( - window_name=f"test_start_dir_{test_id}", - start_directory=start_directory, + window_name=f"test_window_{test_id}", + start_directory=actual_start_directory, ) - # Verify window was created successfully - assert window.window_name == f"test_start_dir_{test_id}" + assert window.window_name == f"test_window_{test_id}" assert window in session.windows + # Verify working directory if we have an expected path + if expected_path: + active_pane = window.active_pane + assert active_pane is not None + active_pane.refresh() + if active_pane.pane_current_path: + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + assert actual_path == expected_path -def test_new_window_start_directory_pathlib(session: Session) -> None: - """Test Session.new_window accepts pathlib.Path for start_directory.""" - import tempfile - with tempfile.TemporaryDirectory() as temp_dir: - path_obj = pathlib.Path(temp_dir) +def test_new_window_start_directory_pathlib( + session: Session, user_path: pathlib.Path +) -> None: + """Test Session.new_window accepts pathlib.Path for start_directory.""" + # Pass pathlib.Path directly to test pathlib.Path acceptance + window = session.new_window( + window_name="test_pathlib_start_dir", + start_directory=user_path, + ) - # Should accept pathlib.Path without error - window = session.new_window( - window_name="test_pathlib_start_dir", - start_directory=path_obj, - ) + assert window.window_name == "test_pathlib_start_dir" + assert window in session.windows - assert window.window_name == "test_pathlib_start_dir" - assert window in session.windows + # Verify working directory + active_pane = window.active_pane + assert active_pane is not None + active_pane.refresh() + if active_pane.pane_current_path: + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_window.py b/tests/test_window.py index 4eb61064e..f5b65357c 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -662,8 +662,6 @@ class StartDirectoryTestFixture(t.NamedTuple): test_id: str start_directory: StrPath | None - expected_in_cmd: list[str] - expected_not_in_cmd: list[str] description: str @@ -671,30 +669,22 @@ class StartDirectoryTestFixture(t.NamedTuple): StartDirectoryTestFixture( test_id="none_value", start_directory=None, - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="None should not add -c flag", ), StartDirectoryTestFixture( test_id="empty_string", start_directory="", - expected_in_cmd=[], - expected_not_in_cmd=["-c"], description="Empty string should not add -c flag", ), StartDirectoryTestFixture( - test_id="absolute_path_string", - start_directory="/tmp/test", - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="Absolute path string should add -c flag", + test_id="user_path", + start_directory="{user_path}", + description="User path should add -c flag", ), StartDirectoryTestFixture( - test_id="pathlib_absolute", - start_directory=pathlib.Path("/tmp/test"), - expected_in_cmd=["-c"], - expected_not_in_cmd=[], - description="pathlib.Path absolute should add -c flag", + test_id="relative_path", + start_directory="./relative/path", + description="Relative path should add -c flag", ), ] @@ -707,33 +697,59 @@ class StartDirectoryTestFixture(t.NamedTuple): def test_split_start_directory( test_id: str, start_directory: StrPath | None, - expected_in_cmd: list[str], - expected_not_in_cmd: list[str], description: str, session: Session, + tmp_path: pathlib.Path, + user_path: pathlib.Path, ) -> None: """Test Window.split start_directory parameter handling.""" window = session.new_window(window_name=f"test_window_split_{test_id}") - # Split window with start_directory parameter - new_pane = window.split(start_directory=start_directory) + # Format path placeholders with actual fixture values + actual_start_directory = start_directory + expected_path = None + + if start_directory and str(start_directory) not in ["", "None"]: + if "{user_path}" in str(start_directory): + # Replace placeholder with actual user_path + actual_start_directory = str(start_directory).format(user_path=user_path) + expected_path = str(user_path) + elif str(start_directory).startswith("./"): + # For relative paths, use tmp_path as base + temp_dir = tmp_path / "relative" / "path" + temp_dir.mkdir(parents=True, exist_ok=True) + actual_start_directory = str(temp_dir) + expected_path = str(temp_dir.resolve()) + + # Should not raise an error + new_pane = window.split(start_directory=actual_start_directory) - # Verify pane was created successfully assert new_pane in window.panes assert len(window.panes) == 2 + # Verify working directory if we have an expected path + if expected_path: + new_pane.refresh() + if new_pane.pane_current_path: + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + assert actual_path == expected_path -def test_split_start_directory_pathlib(session: Session) -> None: - """Test Window.split accepts pathlib.Path for start_directory.""" - import tempfile - with tempfile.TemporaryDirectory() as temp_dir: - path_obj = pathlib.Path(temp_dir) +def test_split_start_directory_pathlib( + session: Session, user_path: pathlib.Path +) -> None: + """Test Window.split accepts pathlib.Path for start_directory.""" + window = session.new_window(window_name="test_window_split_pathlib") - window = session.new_window(window_name="test_window_split_pathlib") + # Pass pathlib.Path directly to test pathlib.Path acceptance + new_pane = window.split(start_directory=user_path) - # Should accept pathlib.Path without error - new_pane = window.split(start_directory=path_obj) + assert new_pane in window.panes + assert len(window.panes) == 2 - assert new_pane in window.panes - assert len(window.panes) == 2 + # Verify working directory + new_pane.refresh() + if new_pane.pane_current_path: + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path From 8483a5b019382b789276c96d86a2896550a9df24 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 May 2025 11:36:03 -0500 Subject: [PATCH 12/12] tests(start_directory) Improve checks what: - Added monkeypatching to change the current working directory to tmp_path in test cases. - Simplified assertions for current path checks by removing unnecessary conditional statements. - Ensured consistency in handling expected paths across test files: test_pane.py, test_server.py, test_session.py, and test_window.py. --- tests/test_pane.py | 17 ++++++++++------- tests/test_server.py | 17 ++++++++++------- tests/test_session.py | 17 ++++++++++------- tests/test_window.py | 17 ++++++++++------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/tests/test_pane.py b/tests/test_pane.py index 7133c85d1..2cb9183ce 100644 --- a/tests/test_pane.py +++ b/tests/test_pane.py @@ -382,10 +382,13 @@ def test_split_start_directory( start_directory: StrPath | None, description: str, session: Session, + monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path, user_path: pathlib.Path, ) -> None: """Test Pane.split start_directory parameter handling.""" + monkeypatch.chdir(tmp_path) + window = session.new_window(window_name=f"test_split_{test_id}") pane = window.active_pane assert pane is not None @@ -415,9 +418,9 @@ def test_split_start_directory( # Verify working directory if we have an expected path if expected_path: new_pane.refresh() - if new_pane.pane_current_path: - actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) - assert actual_path == expected_path + assert new_pane.pane_current_path is not None + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + assert actual_path == expected_path def test_split_start_directory_pathlib( @@ -436,7 +439,7 @@ def test_split_start_directory_pathlib( # Verify working directory new_pane.refresh() - if new_pane.pane_current_path: - actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) - expected_path = str(user_path.resolve()) - assert actual_path == expected_path + assert new_pane.pane_current_path is not None + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_server.py b/tests/test_server.py index 6a94604ea..634ebdc97 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -354,10 +354,13 @@ def test_new_session_start_directory( start_directory: StrPath | None, description: str, server: Server, + monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path, user_path: pathlib.Path, ) -> None: """Test Server.new_session start_directory parameter handling.""" + monkeypatch.chdir(tmp_path) + # Format path placeholders with actual fixture values actual_start_directory = start_directory expected_path = None @@ -388,9 +391,9 @@ def test_new_session_start_directory( active_pane = session.active_window.active_pane assert active_pane is not None active_pane.refresh() - if active_pane.pane_current_path: - actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) - assert actual_path == expected_path + assert active_pane.pane_current_path is not None + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + assert actual_path == expected_path def test_new_session_start_directory_pathlib( @@ -410,7 +413,7 @@ def test_new_session_start_directory_pathlib( active_pane = session.active_window.active_pane assert active_pane is not None active_pane.refresh() - if active_pane.pane_current_path: - actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) - expected_path = str(user_path.resolve()) - assert actual_path == expected_path + assert active_pane.pane_current_path is not None + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_session.py b/tests/test_session.py index f52112091..432fbfdee 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -477,10 +477,13 @@ def test_new_window_start_directory( start_directory: StrPath | None, description: str, session: Session, + monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path, user_path: pathlib.Path, ) -> None: """Test Session.new_window start_directory parameter handling.""" + monkeypatch.chdir(tmp_path) + # Format path placeholders with actual fixture values actual_start_directory = start_directory expected_path = None @@ -511,9 +514,9 @@ def test_new_window_start_directory( active_pane = window.active_pane assert active_pane is not None active_pane.refresh() - if active_pane.pane_current_path: - actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) - assert actual_path == expected_path + assert active_pane.pane_current_path is not None + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + assert actual_path == expected_path def test_new_window_start_directory_pathlib( @@ -533,7 +536,7 @@ def test_new_window_start_directory_pathlib( active_pane = window.active_pane assert active_pane is not None active_pane.refresh() - if active_pane.pane_current_path: - actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) - expected_path = str(user_path.resolve()) - assert actual_path == expected_path + assert active_pane.pane_current_path is not None + actual_path = str(pathlib.Path(active_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path diff --git a/tests/test_window.py b/tests/test_window.py index f5b65357c..ace5eb83c 100644 --- a/tests/test_window.py +++ b/tests/test_window.py @@ -699,10 +699,13 @@ def test_split_start_directory( start_directory: StrPath | None, description: str, session: Session, + monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path, user_path: pathlib.Path, ) -> None: """Test Window.split start_directory parameter handling.""" + monkeypatch.chdir(tmp_path) + window = session.new_window(window_name=f"test_window_split_{test_id}") # Format path placeholders with actual fixture values @@ -730,9 +733,9 @@ def test_split_start_directory( # Verify working directory if we have an expected path if expected_path: new_pane.refresh() - if new_pane.pane_current_path: - actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) - assert actual_path == expected_path + assert new_pane.pane_current_path is not None + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + assert actual_path == expected_path def test_split_start_directory_pathlib( @@ -749,7 +752,7 @@ def test_split_start_directory_pathlib( # Verify working directory new_pane.refresh() - if new_pane.pane_current_path: - actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) - expected_path = str(user_path.resolve()) - assert actual_path == expected_path + assert new_pane.pane_current_path is not None + actual_path = str(pathlib.Path(new_pane.pane_current_path).resolve()) + expected_path = str(user_path.resolve()) + assert actual_path == expected_path