66
77from __future__ import annotations
88
9+ import time
10+
911
1012def test_basic_test_server (TestServer ) -> None :
1113 """Test creating and using a server via TestServer fixture."""
12- # TestServer returns a partial Server class that we can instantiate
13- ServerClass = TestServer () # Get uniquely configured Server class
14- server = ServerClass # This is already an instance, not a class
14+ # TestServer returns a factory that creates servers with unique socket names
15+ server = TestServer () # Create a server with a unique socket name
1516
17+ # Create a session but we don't need to reference it
1618 server .new_session ()
1719 assert server .is_alive ()
1820
@@ -26,32 +28,32 @@ def test_with_config(TestServer, tmp_path) -> None:
2628 config_file .write_text ("set -g status off" )
2729
2830 # Create a server using this configuration
29- ServerClass = TestServer ()
30- # Override the server with a new one that uses our config
31- server = type (ServerClass )(config_file = str (config_file ))
31+ server = TestServer (config_file = str (config_file ))
32+
33+ # Start the server explicitly by creating a session
34+ server .new_session ()
35+
36+ # Give tmux a moment to start up
37+ time .sleep (0.5 )
3238
3339 # Verify the server is running
3440 assert server .is_alive ()
3541
3642 # Create a session to work with
37- server .new_session ()
38-
39- # Optional: Verify the configuration was applied
40- # This would require specific tests for the status being off
43+ session = server .new_session (session_name = "test_config" )
44+ assert session .name == "test_config"
4145
4246 # Clean up is automatic at the end of the test
4347
4448
4549def test_multiple_independent_servers (TestServer ) -> None :
4650 """Test running multiple independent tmux servers simultaneously."""
4751 # Create first server
48- ServerClass1 = TestServer ()
49- server1 = ServerClass1 # This is already an instance
52+ server1 = TestServer ()
5053 session1 = server1 .new_session (session_name = "session1" )
5154
5255 # Create second server (completely independent)
53- ServerClass2 = TestServer ()
54- server2 = ServerClass2 # This is already an instance
56+ server2 = TestServer ()
5557 session2 = server2 .new_session (session_name = "session2" )
5658
5759 # Verify both servers are running
0 commit comments