2626
2727
2828@pytest .mark .parametrize ("node_class" , ["urllib3" , "requests" ])
29- def test_simple_request (node_class , httpbin_node_config ):
29+ def test_simple_request (node_class , httpbin_node_config , httpbin ):
3030 t = Transport ([httpbin_node_config ], node_class = node_class )
3131
3232 resp , data = t .perform_request (
@@ -37,7 +37,7 @@ def test_simple_request(node_class, httpbin_node_config):
3737 )
3838 assert resp .status == 200
3939 assert data ["method" ] == "GET"
40- assert data ["url" ] == "http://localhost:8080 /anything?key[]=1&key[]=2&q1&q2="
40+ assert data ["url" ] == f" { httpbin . url } /anything?key[]=1&key[]=2&q1&q2="
4141
4242 # httpbin makes no-value query params into ''
4343 assert data ["args" ] == {
@@ -53,13 +53,13 @@ def test_simple_request(node_class, httpbin_node_config):
5353 "Content-Length" : "15" ,
5454 "Custom" : "headeR" ,
5555 "Connection" : "keep-alive" ,
56- "Host" : "localhost:8080 " ,
56+ "Host" : f" { httpbin . host } : { httpbin . port } " ,
5757 }
5858 assert all (v == data ["headers" ][k ] for k , v in request_headers .items ())
5959
6060
6161@pytest .mark .parametrize ("node_class" , ["urllib3" , "requests" ])
62- def test_node (node_class , httpbin_node_config ):
62+ def test_node (node_class , httpbin_node_config , httpbin ):
6363 def new_node (** kwargs ):
6464 return NODE_CLASS_NAMES [node_class ](
6565 dataclasses .replace (httpbin_node_config , ** kwargs )
@@ -73,11 +73,11 @@ def new_node(**kwargs):
7373 "headers" : {
7474 "Accept-Encoding" : "identity" ,
7575 "Connection" : "keep-alive" ,
76- "Host" : "localhost:8080 " ,
76+ "Host" : f" { httpbin . host } : { httpbin . port } " ,
7777 "User-Agent" : DEFAULT_USER_AGENT ,
7878 },
7979 "method" : "GET" ,
80- "url" : "http://localhost:8080 /anything" ,
80+ "url" : f" { httpbin . url } /anything" ,
8181 }
8282
8383 node = new_node (http_compress = True )
@@ -88,11 +88,11 @@ def new_node(**kwargs):
8888 "headers" : {
8989 "Accept-Encoding" : "gzip" ,
9090 "Connection" : "keep-alive" ,
91- "Host" : "localhost:8080 " ,
91+ "Host" : f" { httpbin . host } : { httpbin . port } " ,
9292 "User-Agent" : DEFAULT_USER_AGENT ,
9393 },
9494 "method" : "GET" ,
95- "url" : "http://localhost:8080 /anything" ,
95+ "url" : f" { httpbin . url } /anything" ,
9696 }
9797
9898 resp , data = node .perform_request ("GET" , "/anything" , body = b"hello, world!" )
@@ -104,11 +104,11 @@ def new_node(**kwargs):
104104 "Content-Encoding" : "gzip" ,
105105 "Content-Length" : "33" ,
106106 "Connection" : "keep-alive" ,
107- "Host" : "localhost:8080 " ,
107+ "Host" : f" { httpbin . host } : { httpbin . port } " ,
108108 "User-Agent" : DEFAULT_USER_AGENT ,
109109 },
110110 "method" : "GET" ,
111- "url" : "http://localhost:8080 /anything" ,
111+ "url" : f" { httpbin . url } /anything" ,
112112 }
113113
114114 resp , data = node .perform_request (
@@ -126,11 +126,11 @@ def new_node(**kwargs):
126126 "Content-Length" : "36" ,
127127 "Content-Type" : "application/json" ,
128128 "Connection" : "keep-alive" ,
129- "Host" : "localhost:8080 " ,
129+ "Host" : f" { httpbin . host } : { httpbin . port } " ,
130130 "User-Agent" : DEFAULT_USER_AGENT ,
131131 },
132132 "method" : "POST" ,
133- "url" : "http://localhost:8080 /anything" ,
133+ "url" : f" { httpbin . url } /anything" ,
134134 }
135135
136136
0 commit comments