5
5
import json
6
6
import shutil
7
7
from pathlib import Path
8
+ from contextlib import nullcontext
8
9
9
10
import psutil
10
11
import pytest
11
12
12
13
from gaps .status import HardwareStatusRetriever , StatusOption , Status
13
14
from gaps .cli .status import status_command
15
+ from gaps ._cli import main
14
16
from gaps .warnings import gapsWarning
15
17
16
18
36
38
+ "-s dne" .split (),
37
39
],
38
40
)
39
- def test_status (test_data_dir , cli_runner , extra_args , monkeypatch ):
41
+ @pytest .mark .parametrize ("test_main_entry" , [True , False ])
42
+ def test_status (
43
+ test_data_dir , cli_runner , extra_args , test_main_entry , monkeypatch
44
+ ):
40
45
"""Test the status command."""
41
46
42
47
monkeypatch .setattr (psutil , "pid_exists" , lambda * __ : True , raising = True )
@@ -47,18 +52,23 @@ def test_status(test_data_dir, cli_runner, extra_args, monkeypatch):
47
52
raising = True ,
48
53
)
49
54
50
- status = status_command ()
55
+ if test_main_entry :
56
+ status = main
57
+ command_args = ["status" ]
58
+ else :
59
+ status = status_command ()
60
+ command_args = []
61
+
62
+ command_args += [(test_data_dir / "test_run" ).as_posix ()] + extra_args
63
+
51
64
if "dne" in extra_args :
52
- with pytest .warns (gapsWarning ):
53
- result = cli_runner .invoke (
54
- status ,
55
- [(test_data_dir / "test_run" ).as_posix ()] + extra_args ,
56
- )
65
+ expected_behavior = pytest .warns (gapsWarning )
57
66
else :
58
- result = cli_runner .invoke (
59
- status ,
60
- [(test_data_dir / "test_run" ).as_posix ()] + extra_args ,
61
- )
67
+ expected_behavior = nullcontext ()
68
+
69
+ with expected_behavior :
70
+ result = cli_runner .invoke (status , command_args )
71
+
62
72
lines = result .stdout .split ("\n " )
63
73
cols = [
64
74
"job_status" ,
@@ -299,6 +309,7 @@ def test_recursive_status(tmp_path, test_data_dir, cli_runner, monkeypatch):
299
309
assert any (line == "test_run:" for line in lines )
300
310
assert any (line == "test_failed_run:" for line in lines )
301
311
assert len (lines ) > 20
312
+ assert not any (Status .HIDDEN_SUB_DIR in line for line in lines )
302
313
303
314
304
315
if __name__ == "__main__" :
0 commit comments