Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4008209

Browse filesBrowse files
committed
Test SlowretreivalError in RequestsFetcher
Add test_read_timeout to test for urllib3.ReadTimeoutError -> tuf.SlowRetrievalError. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
1 parent deec2ea commit 4008209
Copy full SHA for 4008209

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Collapse file

‎tests/test_fetcher_ng.py‎

Copy file name to clipboardExpand all lines: tests/test_fetcher_ng.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ def test_http_error(self):
107107
self.fetcher.fetch(self.url)
108108
self.assertEqual(cm.exception.status_code, 404)
109109

110+
# Read timeout error
111+
def test_read_timeout(self):
112+
# Reduce the read socket timeout to speed up the test
113+
# while keeping the connect timeout
114+
default_socket_timeout = self.fetcher.socket_timeout
115+
self.fetcher.socket_timeout = (default_socket_timeout, 0.1)
116+
# Launch a new "slow retrieval" server sending one byte each 40s
117+
slow_server_process_handler = utils.TestServerProcess(log=logger, server='slow_retrieval_server.py')
118+
self.url = f"http://{utils.TEST_HOST_ADDRESS}:{str(slow_server_process_handler.port)}/{self.rel_target_filepath}"
119+
with self.assertRaises(exceptions.SlowRetrievalError):
120+
next(self.fetcher.fetch(self.url))
121+
122+
slow_server_process_handler.clean()
123+
110124
# Simple bytes download
111125
def test_download_bytes(self):
112126
data = self.fetcher.download_bytes(self.url, self.file_length)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.