@@ -62,81 +62,29 @@ def test_default_timeout() -> None:
6262 assert cloud_reco_client .request_timeout_seconds == expected
6363
6464 @staticmethod
65- def test_custom_timeout (image : io .BytesIO | BinaryIO ) -> None :
66- """It is possible to set a custom request timeout as a float."""
67- with MockVWS () as mock :
68- database = VuforiaDatabase ()
69- mock .add_database (database = database )
70- vws_client = VWS (
71- server_access_key = database .server_access_key ,
72- server_secret_key = database .server_secret_key ,
73- )
74- custom_timeout = 60.5
75- cloud_reco_client = CloudRecoService (
76- client_access_key = database .client_access_key ,
77- client_secret_key = database .client_secret_key ,
78- request_timeout_seconds = custom_timeout ,
79- )
80- assert cloud_reco_client .request_timeout_seconds == custom_timeout
81-
82- # Verify requests work with the custom timeout
83- target_id = vws_client .add_target (
84- name = "x" ,
85- width = 1 ,
86- image = image ,
87- active_flag = True ,
88- application_metadata = None ,
89- )
90- vws_client .wait_for_target_processed (target_id = target_id )
91- matches = cloud_reco_client .query (image = image )
92- assert len (matches ) == 1
93-
94- @staticmethod
95- def test_custom_timeout_int (image : io .BytesIO | BinaryIO ) -> None :
96- """It is possible to set a custom request timeout as an int."""
97- with MockVWS () as mock :
98- database = VuforiaDatabase ()
99- mock .add_database (database = database )
100- vws_client = VWS (
101- server_access_key = database .server_access_key ,
102- server_secret_key = database .server_secret_key ,
103- )
104- custom_timeout = 60
105- cloud_reco_client = CloudRecoService (
106- client_access_key = database .client_access_key ,
107- client_secret_key = database .client_secret_key ,
108- request_timeout_seconds = custom_timeout ,
109- )
110- assert cloud_reco_client .request_timeout_seconds == custom_timeout
111-
112- target_id = vws_client .add_target (
113- name = "x" ,
114- width = 1 ,
115- image = image ,
116- active_flag = True ,
117- application_metadata = None ,
118- )
119- vws_client .wait_for_target_processed (target_id = target_id )
120- matches = cloud_reco_client .query (image = image )
121- assert len (matches ) == 1
122-
123- @staticmethod
124- def test_custom_timeout_tuple (image : io .BytesIO | BinaryIO ) -> None :
125- """It is possible to set separate connect and read timeouts."""
65+ @pytest .mark .parametrize (
66+ argnames = "custom_timeout" ,
67+ argvalues = [60.5 , 60 , (5.0 , 30.0 )],
68+ )
69+ def test_custom_timeout (
70+ image : io .BytesIO | BinaryIO ,
71+ custom_timeout : int | float | tuple [float , float ], # noqa: PYI041
72+ ) -> None :
73+ """It is possible to set a custom request timeout."""
12674 with MockVWS () as mock :
12775 database = VuforiaDatabase ()
12876 mock .add_database (database = database )
12977 vws_client = VWS (
13078 server_access_key = database .server_access_key ,
13179 server_secret_key = database .server_secret_key ,
13280 )
133- custom_timeout = (5.0 , 30.0 )
13481 cloud_reco_client = CloudRecoService (
13582 client_access_key = database .client_access_key ,
13683 client_secret_key = database .client_secret_key ,
13784 request_timeout_seconds = custom_timeout ,
13885 )
139- assert cloud_reco_client .request_timeout_seconds == custom_timeout
86+ expected = custom_timeout
87+ assert cloud_reco_client .request_timeout_seconds == expected
14088
14189 target_id = vws_client .add_target (
14290 name = "x" ,
0 commit comments