Skip to content

Commit 40d6d56

Browse files
committed
refactor(test): Remove curjoin, use FIXTURE_PATH
1 parent b3d334a commit 40d6d56

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

tests/fixtures/_util.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import os
21
import pathlib
32

43
FIXTURE_PATH = pathlib.Path(__file__).parent
54

65

7-
def curjoin(_file): # return filepath relative to __file__ (this file)
8-
return os.path.join(os.path.dirname(__file__), _file)
9-
10-
116
def loadfixture(_file): # return fixture data, relative to __file__
12-
return open(curjoin(_file)).read()
7+
return open(FIXTURE_PATH / _file).read()
138

149

1510
def write_config(

tests/test_cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
)
2929
from tmuxp.workspacebuilder import WorkspaceBuilder
3030

31-
from .fixtures._util import curjoin, loadfixture
31+
from .fixtures._util import FIXTURE_PATH, loadfixture
3232

3333

3434
def test_creates_config_dir_not_exists(tmp_path: pathlib.Path):
@@ -305,7 +305,7 @@ def test_load_workspace(server, monkeypatch):
305305
# a tmux session by the developer himself, delete the TMUX variable
306306
# temporarily.
307307
monkeypatch.delenv("TMUX", raising=False)
308-
session_file = curjoin("workspacebuilder/two_pane.yaml")
308+
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"
309309

310310
# open it detached
311311
session = load_workspace(
@@ -321,7 +321,7 @@ def test_load_workspace_named_session(server, monkeypatch):
321321
# a tmux session by the developer himself, delete the TMUX variable
322322
# temporarily.
323323
monkeypatch.delenv("TMUX", raising=False)
324-
session_file = curjoin("workspacebuilder/two_pane.yaml")
324+
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"
325325

326326
# open it detached
327327
session = load_workspace(
@@ -342,7 +342,7 @@ def test_load_workspace_name_match_regression_252(
342342
tmp_path: pathlib.Path, server, monkeypatch
343343
):
344344
monkeypatch.delenv("TMUX", raising=False)
345-
session_file = curjoin("workspacebuilder/two_pane.yaml")
345+
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"
346346

347347
# open it detached
348348
session = load_workspace(
@@ -407,8 +407,8 @@ def test_load_symlinked_workspace(server, tmp_path, monkeypatch):
407407
def test_regression_00132_session_name_with_dots(
408408
tmp_path: pathlib.Path, server, session
409409
):
410-
yaml_config = curjoin("workspacebuilder/regression_00132_dots.yaml")
411-
cli_args = [yaml_config]
410+
yaml_config = FIXTURE_PATH / "workspacebuilder" / "regression_00132_dots.yaml"
411+
cli_args = [str(yaml_config)]
412412
inputs = []
413413
runner = CliRunner()
414414
result = runner.invoke(
@@ -1181,7 +1181,7 @@ def test_plugin_system_before_script(
11811181
# a tmux session by the developer himself, delete the TMUX variable
11821182
# temporarily.
11831183
monkeypatch.delenv("TMUX", raising=False)
1184-
session_file = curjoin("workspacebuilder/plugin_bs.yaml")
1184+
session_file = FIXTURE_PATH / "workspacebuilder" / "plugin_bs.yaml"
11851185

11861186
# open it detached
11871187
session = load_workspace(

0 commit comments

Comments
 (0)