Skip to content

Commit 46bb4df

Browse files
committed
refactor(test): load_fixture -> read_config_file
Less ambiguity
1 parent 489d9fd commit 46bb4df

14 files changed

+73
-69
lines changed

tests/fixtures/_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FIXTURE_PATH = pathlib.Path(__file__).parent
44

55

6-
def load_fixture(_file): # return fixture data, relative to __file__
6+
def read_config_file(_file): # return fixture data, relative to __file__
77
return open(FIXTURE_PATH / _file).read()
88

99

tests/fixtures/config/expand2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22

3-
from .._util import load_fixture
3+
from .._util import read_config_file
44

5-
unexpanded_yaml = load_fixture("config/expand2-unexpanded.yaml")
6-
expanded_yaml = load_fixture("config/expand2-expanded.yaml").format(
5+
unexpanded_yaml = read_config_file("config/expand2-unexpanded.yaml")
6+
expanded_yaml = read_config_file("config/expand2-expanded.yaml").format(
77
HOME=os.path.expanduser("~")
88
)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
before = load_fixture("config/shell_command_before_session.yaml")
4-
expected = load_fixture("config/shell_command_before_session-expected.yaml")
3+
before = read_config_file("config/shell_command_before_session.yaml")
4+
expected = read_config_file("config/shell_command_before_session-expected.yaml")

tests/fixtures/config_teamocil/layouts.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
teamocil_yaml = load_fixture("config_teamocil/layouts.yaml")
3+
teamocil_yaml = read_config_file("config_teamocil/layouts.yaml")
44

55
teamocil_dict = {
66
"two-windows": {

tests/fixtures/config_teamocil/test1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
teamocil_yaml = load_fixture("config_teamocil/test1.yaml")
3+
teamocil_yaml = read_config_file("config_teamocil/test1.yaml")
44
teamocil_conf = {
55
"windows": [
66
{

tests/fixtures/config_teamocil/test2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
teamocil_yaml = load_fixture("config_teamocil/test2.yaml")
3+
teamocil_yaml = read_config_file("config_teamocil/test2.yaml")
44
teamocil_dict = {
55
"windows": [
66
{

tests/fixtures/config_teamocil/test3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
teamocil_yaml = load_fixture("config_teamocil/test3.yaml")
3+
teamocil_yaml = read_config_file("config_teamocil/test3.yaml")
44

55
teamocil_dict = {
66
"windows": [

tests/fixtures/config_teamocil/test4.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
teamocil_yaml = load_fixture("config_teamocil/test4.yaml")
3+
teamocil_yaml = read_config_file("config_teamocil/test4.yaml")
44

55
teamocil_dict = {
66
"windows": [

tests/fixtures/config_tmuxinator/test1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
tmuxinator_yaml = load_fixture("config_tmuxinator/test1.yaml")
3+
tmuxinator_yaml = read_config_file("config_tmuxinator/test1.yaml")
44
tmuxinator_dict = {
55
"windows": [
66
{"editor": {"layout": "main-vertical", "panes": ["vim", "guard"]}},

tests/fixtures/config_tmuxinator/test2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
tmuxinator_yaml = load_fixture("config_tmuxinator/test2.yaml")
3+
tmuxinator_yaml = read_config_file("config_tmuxinator/test2.yaml")
44

55
tmuxinator_dict = {
66
"project_name": "sample",

tests/fixtures/config_tmuxinator/test3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._util import load_fixture
1+
from .._util import read_config_file
22

3-
tmuxinator_yaml = load_fixture("config_tmuxinator/test3.yaml")
3+
tmuxinator_yaml = read_config_file("config_tmuxinator/test3.yaml")
44

55
tmuxinator_dict = {
66
"name": "sample",

tests/test_cli.py

+10-10
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 FIXTURE_PATH, load_fixture
31+
from .fixtures._util import FIXTURE_PATH, read_config_file
3232

3333

3434
def test_creates_config_dir_not_exists(tmp_path: pathlib.Path):
@@ -861,7 +861,7 @@ def test_help(cli_args, monkeypatch):
861861
],
862862
)
863863
def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
864-
teamocil_config = load_fixture("config_teamocil/test4.yaml")
864+
teamocil_config = read_config_file("config_teamocil/test4.yaml")
865865

866866
teamocil_path = tmp_path / ".teamocil"
867867
teamocil_path.mkdir()
@@ -900,7 +900,7 @@ def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
900900
],
901901
)
902902
def test_import_tmuxinator(cli_args, inputs, tmp_path, monkeypatch):
903-
tmuxinator_config = load_fixture("config_tmuxinator/test3.yaml")
903+
tmuxinator_config = read_config_file("config_tmuxinator/test3.yaml")
904904

905905
tmuxinator_path = tmp_path / ".tmuxinator"
906906
tmuxinator_path.mkdir()
@@ -1103,7 +1103,7 @@ def test_ls_cli(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path):
11031103
def test_load_plugins(monkeypatch_plugin_test_packages):
11041104
from tmuxp_test_plugin_bwb.plugin import PluginBeforeWorkspaceBuilder
11051105

1106-
plugins_config = load_fixture("workspacebuilder/plugin_bwb.yaml")
1106+
plugins_config = read_config_file("workspacebuilder/plugin_bwb.yaml")
11071107

11081108
sconfig = kaptan.Kaptan(handler="yaml")
11091109
sconfig = sconfig.import_config(plugins_config).get()
@@ -1186,7 +1186,7 @@ def test_plugin_system_before_script(
11861186

11871187

11881188
def test_reattach_plugins(monkeypatch_plugin_test_packages, server):
1189-
config_plugins = load_fixture("workspacebuilder/plugin_r.yaml")
1189+
config_plugins = read_config_file("workspacebuilder/plugin_r.yaml")
11901190

11911191
sconfig = kaptan.Kaptan(handler="yaml")
11921192
sconfig = sconfig.import_config(config_plugins).get()
@@ -1217,7 +1217,7 @@ def test_load_attached(server, monkeypatch):
12171217

12181218
monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)
12191219

1220-
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
1220+
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
12211221
sconfig = kaptan.Kaptan(handler="yaml")
12221222
sconfig = sconfig.import_config(yaml_config).get()
12231223

@@ -1237,7 +1237,7 @@ def test_load_attached_detached(server, monkeypatch):
12371237

12381238
monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)
12391239

1240-
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
1240+
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
12411241
sconfig = kaptan.Kaptan(handler="yaml")
12421242
sconfig = sconfig.import_config(yaml_config).get()
12431243

@@ -1257,7 +1257,7 @@ def test_load_attached_within_tmux(server, monkeypatch):
12571257

12581258
monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)
12591259

1260-
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
1260+
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
12611261
sconfig = kaptan.Kaptan(handler="yaml")
12621262
sconfig = sconfig.import_config(yaml_config).get()
12631263

@@ -1277,7 +1277,7 @@ def test_load_attached_within_tmux_detached(server, monkeypatch):
12771277

12781278
monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)
12791279

1280-
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
1280+
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
12811281
sconfig = kaptan.Kaptan(handler="yaml")
12821282
sconfig = sconfig.import_config(yaml_config).get()
12831283

@@ -1289,7 +1289,7 @@ def test_load_attached_within_tmux_detached(server, monkeypatch):
12891289

12901290

12911291
def test_load_append_windows_to_current_session(server, monkeypatch):
1292-
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
1292+
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
12931293
sconfig = kaptan.Kaptan(handler="yaml")
12941294
sconfig = sconfig.import_config(yaml_config).get()
12951295

0 commit comments

Comments
 (0)