22
33from __future__ import annotations
44
5- from typing import Any , Dict
5+ from typing import TYPE_CHECKING , Any
66
77import pytest
8- from _pytest .fixtures import FixtureRequest
98
10- from libtmux import Server
11- from libtmux . pytest_plugin import TestServer
9+ if TYPE_CHECKING :
10+ from libtmux import Server
1211
1312
1413@pytest .fixture
15- def custom_config (request : FixtureRequest ) -> Dict [str , Any ]:
14+ def custom_config () -> dict [str , Any ]:
1615 """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
2021 """
2122 return {
2223 "colors" : 256 ,
@@ -25,45 +26,31 @@ def custom_config(request: FixtureRequest) -> Dict[str, Any]:
2526 }
2627
2728
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
3534
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
4237 assert colors is not None
4338
4439
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"
5745
5846 # Create multiple windows
5947 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 } " )
6251 windows .append (window )
6352
6453 # Verify windows were created
65- assert len (session .windows ) >= 3
54+ assert len (new_session .windows ) >= expected_window_count
6655 for i , window in enumerate (windows ):
6756 assert f"window-{ i } " == window .window_name
68-
69- # Server is automatically cleaned up by pytest
0 commit comments