14
14
from libtmux .common import has_lt_version
15
15
from libtmux .exc import LibTmuxException
16
16
from tmuxp import cli , config , exc
17
- from tmuxp .cli import (
17
+ from tmuxp .cli .debug_info import command_debug_info
18
+ from tmuxp .cli .import_config import get_teamocil_dir , get_tmuxinator_dir
19
+ from tmuxp .cli .load import (
18
20
_load_append_windows_to_current_session ,
19
21
_load_attached ,
20
22
_reattach ,
21
- command_debug_info ,
22
- command_ls ,
23
- get_config_dir ,
24
- is_pure_name ,
25
23
load_plugins ,
26
24
load_workspace ,
25
+ )
26
+ from tmuxp .cli .ls import command_ls
27
+ from tmuxp .cli .utils import (
28
+ ConfigPath ,
29
+ _validate_choices ,
30
+ get_abs_path ,
31
+ get_config_dir ,
32
+ is_pure_name ,
27
33
scan_config ,
28
34
)
29
35
from tmuxp .workspacebuilder import WorkspaceBuilder
@@ -267,7 +273,7 @@ def test_scan_config_arg(
267
273
runner = CliRunner ()
268
274
269
275
@click .command ()
270
- @click .argument ("config" , type = cli . ConfigPath (exists = True ), nargs = - 1 )
276
+ @click .argument ("config" , type = ConfigPath (exists = True ), nargs = - 1 )
271
277
def config_cmd (config ):
272
278
click .echo (config )
273
279
@@ -470,15 +476,15 @@ def test_load_log_file(cli_args, tmp_path, monkeypatch):
470
476
monkeypatch .setenv ("HOME" , str (tmp_path ))
471
477
472
478
monkeypatch .chdir (tmp_path )
473
- print (f"tmp_path: { tmp_path } " )
474
479
runner = CliRunner ()
475
480
476
481
# If autoconfirm (-y) no need to prompt y
477
482
input_args = "y\n y\n " if "-y" not in cli_args else ""
478
483
479
- runner .invoke (cli .cli , cli_args , input = input_args )
484
+ result = runner .invoke (cli .cli , cli_args , input = input_args )
480
485
log_file_path = tmp_path / "log.txt"
481
486
assert "Loading" in log_file_path .open ().read ()
487
+ assert result is not None
482
488
483
489
484
490
@pytest .mark .parametrize ("cli_cmd" , ["shell" , ("shell" , "--pdb" )])
@@ -1002,30 +1008,30 @@ def test_freeze_overwrite(server, cli_args, inputs, tmp_path, monkeypatch):
1002
1008
def test_get_abs_path (tmp_path : pathlib .Path , monkeypatch : pytest .MonkeyPatch ):
1003
1009
expect = str (tmp_path )
1004
1010
monkeypatch .chdir (tmp_path )
1005
- cli . get_abs_path ("../" ) == os .path .dirname (expect )
1006
- cli . get_abs_path ("." ) == expect
1007
- cli . get_abs_path ("./" ) == expect
1008
- cli . get_abs_path (expect ) == expect
1011
+ get_abs_path ("../" ) == os .path .dirname (expect )
1012
+ get_abs_path ("." ) == expect
1013
+ get_abs_path ("./" ) == expect
1014
+ get_abs_path (expect ) == expect
1009
1015
1010
1016
1011
1017
def test_get_tmuxinator_dir (monkeypatch ):
1012
- assert cli . get_tmuxinator_dir () == os .path .expanduser ("~/.tmuxinator/" )
1018
+ assert get_tmuxinator_dir () == os .path .expanduser ("~/.tmuxinator/" )
1013
1019
1014
1020
monkeypatch .setenv ("HOME" , "/moo" )
1015
- assert cli . get_tmuxinator_dir () == "/moo/.tmuxinator/"
1016
- assert cli . get_tmuxinator_dir () == os .path .expanduser ("~/.tmuxinator/" )
1021
+ assert get_tmuxinator_dir () == "/moo/.tmuxinator/"
1022
+ assert get_tmuxinator_dir () == os .path .expanduser ("~/.tmuxinator/" )
1017
1023
1018
1024
1019
1025
def test_get_teamocil_dir (monkeypatch : pytest .MonkeyPatch ):
1020
- assert cli . get_teamocil_dir () == os .path .expanduser ("~/.teamocil/" )
1026
+ assert get_teamocil_dir () == os .path .expanduser ("~/.teamocil/" )
1021
1027
1022
1028
monkeypatch .setenv ("HOME" , "/moo" )
1023
- assert cli . get_teamocil_dir () == "/moo/.teamocil/"
1024
- assert cli . get_teamocil_dir () == os .path .expanduser ("~/.teamocil/" )
1029
+ assert get_teamocil_dir () == "/moo/.teamocil/"
1030
+ assert get_teamocil_dir () == os .path .expanduser ("~/.teamocil/" )
1025
1031
1026
1032
1027
1033
def test_validate_choices ():
1028
- validate = cli . _validate_choices (["choice1" , "choice2" ])
1034
+ validate = _validate_choices (["choice1" , "choice2" ])
1029
1035
1030
1036
assert validate ("choice1" )
1031
1037
assert validate ("choice2" )
@@ -1051,7 +1057,7 @@ def test_pass_config_dir_ClickPath(
1051
1057
@click .command ()
1052
1058
@click .argument (
1053
1059
"config" ,
1054
- type = cli . ConfigPath (exists = True , config_dir = (str (configdir ))),
1060
+ type = ConfigPath (exists = True , config_dir = (str (configdir ))),
1055
1061
nargs = - 1 ,
1056
1062
)
1057
1063
def config_cmd (config ):
0 commit comments