Skip to content

Commit 76f8c8b

Browse files
committed
tests: Add util via namespace
1 parent 46bb4df commit 76f8c8b

13 files changed

+83
-70
lines changed

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 read_config_file
3+
from .. import _util as test_utils
44

5-
unexpanded_yaml = read_config_file("config/expand2-unexpanded.yaml")
6-
expanded_yaml = read_config_file("config/expand2-expanded.yaml").format(
5+
unexpanded_yaml = test_utils.read_config_file("config/expand2-unexpanded.yaml")
6+
expanded_yaml = test_utils.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,6 @@
1-
from .._util import read_config_file
1+
from .. import _util as test_utils
22

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

tests/fixtures/config_teamocil/layouts.py

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

3-
teamocil_yaml = read_config_file("config_teamocil/layouts.yaml")
3+
teamocil_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
teamocil_yaml = read_config_file("config_teamocil/test1.yaml")
3+
teamocil_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
teamocil_yaml = read_config_file("config_teamocil/test2.yaml")
3+
teamocil_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
teamocil_yaml = read_config_file("config_teamocil/test3.yaml")
3+
teamocil_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
teamocil_yaml = read_config_file("config_teamocil/test4.yaml")
3+
teamocil_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
tmuxinator_yaml = read_config_file("config_tmuxinator/test1.yaml")
3+
tmuxinator_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

3-
tmuxinator_yaml = read_config_file("config_tmuxinator/test2.yaml")
3+
tmuxinator_yaml = test_utils.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 read_config_file
1+
from .. import _util as test_utils
22

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

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

tests/test_cli.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
)
2929
from tmuxp.workspacebuilder import WorkspaceBuilder
3030

31-
from .fixtures._util import FIXTURE_PATH, read_config_file
31+
from .fixtures import _util as test_utils
32+
from .fixtures._util import FIXTURE_PATH
3233

3334

3435
def test_creates_config_dir_not_exists(tmp_path: pathlib.Path):
@@ -861,7 +862,7 @@ def test_help(cli_args, monkeypatch):
861862
],
862863
)
863864
def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
864-
teamocil_config = read_config_file("config_teamocil/test4.yaml")
865+
teamocil_config = test_utils.read_config_file("config_teamocil/test4.yaml")
865866

866867
teamocil_path = tmp_path / ".teamocil"
867868
teamocil_path.mkdir()
@@ -900,7 +901,7 @@ def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
900901
],
901902
)
902903
def test_import_tmuxinator(cli_args, inputs, tmp_path, monkeypatch):
903-
tmuxinator_config = read_config_file("config_tmuxinator/test3.yaml")
904+
tmuxinator_config = test_utils.read_config_file("config_tmuxinator/test3.yaml")
904905

905906
tmuxinator_path = tmp_path / ".tmuxinator"
906907
tmuxinator_path.mkdir()
@@ -1103,7 +1104,7 @@ def test_ls_cli(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path):
11031104
def test_load_plugins(monkeypatch_plugin_test_packages):
11041105
from tmuxp_test_plugin_bwb.plugin import PluginBeforeWorkspaceBuilder
11051106

1106-
plugins_config = read_config_file("workspacebuilder/plugin_bwb.yaml")
1107+
plugins_config = test_utils.read_config_file("workspacebuilder/plugin_bwb.yaml")
11071108

11081109
sconfig = kaptan.Kaptan(handler="yaml")
11091110
sconfig = sconfig.import_config(plugins_config).get()
@@ -1186,7 +1187,7 @@ def test_plugin_system_before_script(
11861187

11871188

11881189
def test_reattach_plugins(monkeypatch_plugin_test_packages, server):
1189-
config_plugins = read_config_file("workspacebuilder/plugin_r.yaml")
1190+
config_plugins = test_utils.read_config_file("workspacebuilder/plugin_r.yaml")
11901191

11911192
sconfig = kaptan.Kaptan(handler="yaml")
11921193
sconfig = sconfig.import_config(config_plugins).get()
@@ -1217,7 +1218,7 @@ def test_load_attached(server, monkeypatch):
12171218

12181219
monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)
12191220

1220-
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
1221+
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
12211222
sconfig = kaptan.Kaptan(handler="yaml")
12221223
sconfig = sconfig.import_config(yaml_config).get()
12231224

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

12381239
monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)
12391240

1240-
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
1241+
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
12411242
sconfig = kaptan.Kaptan(handler="yaml")
12421243
sconfig = sconfig.import_config(yaml_config).get()
12431244

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

12581259
monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)
12591260

1260-
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
1261+
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
12611262
sconfig = kaptan.Kaptan(handler="yaml")
12621263
sconfig = sconfig.import_config(yaml_config).get()
12631264

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

12781279
monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)
12791280

1280-
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
1281+
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
12811282
sconfig = kaptan.Kaptan(handler="yaml")
12821283
sconfig = sconfig.import_config(yaml_config).get()
12831284

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

12901291

12911292
def test_load_append_windows_to_current_session(server, monkeypatch):
1292-
yaml_config = read_config_file("workspacebuilder/two_pane.yaml")
1293+
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
12931294
sconfig = kaptan.Kaptan(handler="yaml")
12941295
sconfig = sconfig.import_config(yaml_config).get()
12951296

0 commit comments

Comments
 (0)