2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Any , Dict
5
+ from typing import TYPE_CHECKING , Any
6
6
7
7
import pytest
8
- from _pytest .fixtures import FixtureRequest
9
8
10
- from libtmux import Server
11
- from libtmux . pytest_plugin import TestServer
9
+ if TYPE_CHECKING :
10
+ from libtmux import Server
12
11
13
12
14
13
@pytest .fixture
15
- def custom_config (request : FixtureRequest ) -> Dict [str , Any ]:
14
+ def custom_config () -> dict [str , Any ]:
16
15
"""Fixture providing custom configuration settings.
17
-
18
- Returns:
19
- Dict[str, Any]: Configuration dictionary with tmux settings
16
+
17
+ Returns
18
+ -------
19
+ dict[str, Any]
20
+ Configuration dictionary with tmux settings
20
21
"""
21
22
return {
22
23
"colors" : 256 ,
@@ -25,45 +26,31 @@ def custom_config(request: FixtureRequest) -> Dict[str, Any]:
25
26
}
26
27
27
28
28
- def test_custom_server_config (custom_server : Server ) -> None :
29
- """Test a server with custom configuration."""
30
- # Verify server is running
31
- assert custom_server .is_alive ()
32
-
33
- # Verify custom socket name
34
- assert "custom-socket" in str (custom_server .socket_path or "" )
29
+ def test_server_config (server : Server , session : object ) -> None :
30
+ """Test server configuration."""
31
+ # Create a session and verify it works
32
+ # Note: The session fixture ensures we have an active session already
33
+ assert session is not None
35
34
36
- # Create a session
37
- session = custom_server .new_session (session_name = "custom-test" )
38
- assert session .name == "custom-test"
39
-
40
- # Get color configuration
41
- colors = custom_server .cmd ("show-option" , "-g" , "default-terminal" ).stdout
35
+ # Get color configuration using tmux command
36
+ colors = server .cmd ("show-option" , "-g" , "default-terminal" ).stdout
42
37
assert colors is not None
43
38
44
39
45
- @pytest .mark .usefixtures ("request" )
46
- def test_testserver_direct_usage (request : FixtureRequest ) -> None :
47
- """Test using TestServer directly."""
48
- # Get TestServer fixture function
49
- server_factory = TestServer (request )
50
-
51
- # Create a server using the factory function
52
- server = server_factory ()
53
-
54
- # Create a session
55
- session = server .new_session (session_name = "direct-test" )
56
- assert session .name == "direct-test"
40
+ def test_server_operations (server : Server ) -> None :
41
+ """Test basic server operations."""
42
+ # Create a new session for this test
43
+ new_session = server .new_session (session_name = "ops-test" )
44
+ assert new_session .name == "ops-test"
57
45
58
46
# Create multiple windows
59
47
windows = []
60
- for i in range (3 ):
61
- window = session .new_window (window_name = f"window-{ i } " )
48
+ expected_window_count = 3
49
+ for i in range (expected_window_count ):
50
+ window = new_session .new_window (window_name = f"window-{ i } " )
62
51
windows .append (window )
63
52
64
53
# Verify windows were created
65
- assert len (session .windows ) >= 3
54
+ assert len (new_session .windows ) >= expected_window_count
66
55
for i , window in enumerate (windows ):
67
56
assert f"window-{ i } " == window .window_name
68
-
69
- # Server is automatically cleaned up by pytest
0 commit comments