11"""Test for tmuxp configuration import, inlining, expanding and export."""
22import os
33import pathlib
4- import types
54import typing
65from typing import Union
76
1716 from ..fixtures .structures import WorkspaceTestData
1817
1918
20- @pytest .fixture
21- def config_fixture ():
22- """Deferred import of tmuxp.tests.fixtures.*
23-
24- pytest setup (conftest.py) patches os.environ["HOME"], delay execution of
25- os.path.expanduser until here.
26- """
27- from ..fixtures import workspace as test_workspace_data
28- from ..fixtures .structures import WorkspaceTestData
29-
30- return WorkspaceTestData (
31- ** {
32- k : v
33- for k , v in test_workspace_data .__dict__ .items ()
34- if isinstance (v , types .ModuleType )
35- }
36- )
37-
38-
3919def load_yaml (path : Union [str , pathlib .Path ]) -> str :
4020 return ConfigReader ._from_file (
4121 pathlib .Path (path ) if isinstance (path , str ) else path
@@ -61,22 +41,6 @@ def test_export_json(tmp_path: pathlib.Path, config_fixture: "WorkspaceTestData"
6141 assert config_fixture .sample_workspace .sample_workspace_dict == new_workspace_data
6242
6343
64- def test_export_yaml (tmp_path : pathlib .Path , config_fixture : "WorkspaceTestData" ):
65- yaml_workspace_file = tmp_path / "config.yaml"
66-
67- sample_workspace = config .inline (
68- config_fixture .sample_workspace .sample_workspace_dict
69- )
70- configparser = ConfigReader (sample_workspace )
71-
72- yaml_workspace_data = configparser .dump ("yaml" , indent = 2 , default_flow_style = False )
73-
74- yaml_workspace_file .write_text (yaml_workspace_data , encoding = "utf-8" )
75-
76- new_workspace_data = load_workspace (str (yaml_workspace_file ))
77- assert config_fixture .sample_workspace .sample_workspace_dict == new_workspace_data
78-
79-
8044def test_scan_workspace (tmp_path : pathlib .Path ):
8145 configs = []
8246
@@ -123,49 +87,6 @@ def test_workspace_expand2(config_fixture: "WorkspaceTestData"):
12387 assert config .expand (unexpanded_dict ) == expanded_dict
12488
12589
126- """Tests for :meth:`config.inline()`."""
127-
128- ibefore_workspace = { # inline config
129- "session_name" : "sample workspace" ,
130- "start_directory" : "~" ,
131- "windows" : [
132- {
133- "shell_command" : ["top" ],
134- "window_name" : "editor" ,
135- "panes" : [{"shell_command" : ["vim" ]}, {"shell_command" : ['cowsay "hey"' ]}],
136- "layout" : "main-verticle" ,
137- },
138- {
139- "window_name" : "logging" ,
140- "panes" : [{"shell_command" : ["tail -F /var/log/syslog" ]}],
141- },
142- {"options" : {"automatic-rename" : True }, "panes" : [{"shell_command" : ["htop" ]}]},
143- ],
144- }
145-
146- iafter_workspace = {
147- "session_name" : "sample workspace" ,
148- "start_directory" : "~" ,
149- "windows" : [
150- {
151- "shell_command" : "top" ,
152- "window_name" : "editor" ,
153- "panes" : ["vim" , 'cowsay "hey"' ],
154- "layout" : "main-verticle" ,
155- },
156- {"window_name" : "logging" , "panes" : ["tail -F /var/log/syslog" ]},
157- {"options" : {"automatic-rename" : True }, "panes" : ["htop" ]},
158- ],
159- }
160-
161-
162- def test_inline_workspace ():
163- """:meth:`config.inline()` shell commands list to string."""
164-
165- test_workspace = config .inline (ibefore_workspace )
166- assert test_workspace == iafter_workspace
167-
168-
16990"""Test config inheritance for the nested 'start_command'."""
17091
17192inheritance_workspace_before = {
0 commit comments