@@ -30,7 +30,7 @@ async def test_connection_pool_with_keepalive():
3030    )
3131
3232    async  with  httpcore .AsyncConnectionPool (
33-         network_backend = network_backend ,
33+         network_backend = network_backend ,  max_keepalive_connections = 1 
3434    ) as  pool :
3535        # Sending an intial request, which once complete will return to the pool, IDLE. 
3636        async  with  pool .stream ("GET" , "https://example.com/" ) as  response :
@@ -79,28 +79,33 @@ async def test_connection_pool_with_keepalive():
7979        )
8080
8181        # Sending a request to a different origin will not reuse the existing IDLE connection. 
82-         async  with  pool .stream ("GET" , "http://example.com/" ) as  response :
82+         async  with  pool .stream ("GET" , "http://example.com/" ) as  response_1 , pool .stream (
83+             "GET" , "http://example.com/" 
84+         ) as  response_2 :
8385            info  =  [repr (c ) for  c  in  pool .connections ]
8486            assert  info  ==  [
8587                "<AsyncHTTPConnection ['https://example.com:443', HTTP/1.1, IDLE, Request Count: 2]>" ,
8688                "<AsyncHTTPConnection ['http://example.com:80', HTTP/1.1, ACTIVE, Request Count: 1]>" ,
89+                 "<AsyncHTTPConnection ['http://example.com:80', HTTP/1.1, ACTIVE, Request Count: 1]>" ,
8790            ]
8891            assert  (
8992                repr (pool )
90-                 ==  "<AsyncConnectionPool [Requests: 1  active, 0 queued | Connections: 1  active, 1 idle]>" 
93+                 ==  "<AsyncConnectionPool [Requests: 2  active, 0 queued | Connections: 2  active, 1 idle]>" 
9194            )
92-             await  response .aread ()
95+             await  response_1 .aread ()
96+             await  response_2 .aread ()
9397
94-         assert  response .status  ==  200 
95-         assert  response .content  ==  b"Hello, world!" 
98+         assert  response_1 .status  ==  200 
99+         assert  response_1 .content  ==  b"Hello, world!" 
100+         assert  response_2 .status  ==  200 
101+         assert  response_2 .content  ==  b"Hello, world!" 
96102        info  =  [repr (c ) for  c  in  pool .connections ]
97103        assert  info  ==  [
98-             "<AsyncHTTPConnection ['https://example.com:443', HTTP/1.1, IDLE, Request Count: 2]>" ,
99104            "<AsyncHTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, Request Count: 1]>" ,
100105        ]
101106        assert  (
102107            repr (pool )
103-             ==  "<AsyncConnectionPool [Requests: 0 active, 0 queued | Connections: 0 active, 2  idle]>" 
108+             ==  "<AsyncConnectionPool [Requests: 0 active, 0 queued | Connections: 0 active, 1  idle]>" 
104109        )
105110
106111
0 commit comments