1
1
"""Test for tmuxp configuration import, inlining, expanding and export."""
2
2
import os
3
3
import pathlib
4
+ import types
4
5
import typing
5
6
from typing import Union
6
7
13
14
from .constants import EXAMPLE_PATH
14
15
15
16
if typing .TYPE_CHECKING :
16
- from .fixtures import config as ConfigFixture
17
+ from .fixtures . structures import TestConfigData
17
18
18
19
19
20
@pytest .fixture
@@ -23,9 +24,16 @@ def config_fixture():
23
24
pytest setup (conftest.py) patches os.environ["HOME"], delay execution of
24
25
os.path.expanduser until here.
25
26
"""
26
- from .fixtures import config as config_fixture
27
-
28
- return config_fixture
27
+ from .fixtures import config as test_config_data
28
+ from .fixtures .structures import TestConfigData
29
+
30
+ return TestConfigData (
31
+ ** {
32
+ k : v
33
+ for k , v in test_config_data .__dict__ .items ()
34
+ if isinstance (v , types .ModuleType )
35
+ }
36
+ )
29
37
30
38
31
39
def load_yaml (path : Union [str , pathlib .Path ]) -> str :
@@ -44,7 +52,7 @@ def load_config(path: Union[str, pathlib.Path]) -> str:
44
52
)
45
53
46
54
47
- def test_export_json (tmp_path : pathlib .Path , config_fixture : "ConfigFixture " ):
55
+ def test_export_json (tmp_path : pathlib .Path , config_fixture : "TestConfigData " ):
48
56
json_config_file = tmp_path / "config.json"
49
57
50
58
configparser = kaptan .Kaptan ()
@@ -59,7 +67,7 @@ def test_export_json(tmp_path: pathlib.Path, config_fixture: "ConfigFixture"):
59
67
assert config_fixture .sampleconfig .sampleconfigdict == new_config_data
60
68
61
69
62
- def test_export_yaml (tmp_path : pathlib .Path , config_fixture : "ConfigFixture " ):
70
+ def test_export_yaml (tmp_path : pathlib .Path , config_fixture : "TestConfigData " ):
63
71
yaml_config_file = tmp_path / "config.yaml"
64
72
65
73
configparser = kaptan .Kaptan ()
@@ -103,13 +111,13 @@ def test_scan_config(tmp_path: pathlib.Path):
103
111
assert len (configs ) == files
104
112
105
113
106
- def test_config_expand1 (config_fixture : "ConfigFixture " ):
114
+ def test_config_expand1 (config_fixture : "TestConfigData " ):
107
115
"""Expand shell commands from string to list."""
108
116
test_config = config .expand (config_fixture .expand1 .before_config )
109
117
assert test_config == config_fixture .expand1 .after_config ()
110
118
111
119
112
- def test_config_expand2 (config_fixture : "ConfigFixture " ):
120
+ def test_config_expand2 (config_fixture : "TestConfigData " ):
113
121
"""Expand shell commands from string to list."""
114
122
unexpanded_dict = load_yaml (config_fixture .expand2 .unexpanded_yaml ())
115
123
expanded_dict = load_yaml (config_fixture .expand2 .expanded_yaml ())
@@ -228,7 +236,7 @@ def test_inheritance_config():
228
236
assert config == inheritance_config_after
229
237
230
238
231
- def test_shell_command_before (config_fixture : "ConfigFixture " ):
239
+ def test_shell_command_before (config_fixture : "TestConfigData " ):
232
240
"""Config inheritance for the nested 'start_command'."""
233
241
test_config = config_fixture .shell_command_before .config_unexpanded
234
242
test_config = config .expand (test_config )
@@ -239,7 +247,7 @@ def test_shell_command_before(config_fixture: "ConfigFixture"):
239
247
assert test_config == config_fixture .shell_command_before .config_after ()
240
248
241
249
242
- def test_in_session_scope (config_fixture : "ConfigFixture " ):
250
+ def test_in_session_scope (config_fixture : "TestConfigData " ):
243
251
sconfig = load_yaml (config_fixture .shell_command_before_session .before )
244
252
245
253
config .validate_schema (sconfig )
@@ -250,7 +258,7 @@ def test_in_session_scope(config_fixture: "ConfigFixture"):
250
258
)
251
259
252
260
253
- def test_trickle_relative_start_directory (config_fixture : "ConfigFixture " ):
261
+ def test_trickle_relative_start_directory (config_fixture : "TestConfigData " ):
254
262
test_config = config .trickle (config_fixture .trickle .before )
255
263
assert test_config == config_fixture .trickle .expected
256
264
@@ -273,7 +281,7 @@ def test_trickle_window_with_no_pane_config():
273
281
}
274
282
275
283
276
- def test_expands_blank_panes (config_fixture : "ConfigFixture " ):
284
+ def test_expands_blank_panes (config_fixture : "TestConfigData " ):
277
285
"""Expand blank config into full form.
278
286
279
287
Handle ``NoneType`` and 'blank'::
0 commit comments