net: let localhost RetryServer tests run with an HTTP proxy active

This commit is contained in:
Hans-Christoph Steiner 2024-03-13 21:44:49 +01:00
parent 59fcfa5dec
commit f1b110942a

View file

@ -107,6 +107,7 @@ class NetTest(unittest.TestCase):
self.assertTrue(os.path.exists(f)) self.assertTrue(os.path.exists(f))
self.assertEqual('tmp/com.downloader.aegis-3175421.apk', f) self.assertEqual('tmp/com.downloader.aegis-3175421.apk', f)
@patch.dict(os.environ, clear=True)
def test_download_file_retries(self): def test_download_file_retries(self):
server = RetryServer() server = RetryServer()
f = net.download_file('http://localhost:%d/f.txt' % server.port) f = net.download_file('http://localhost:%d/f.txt' % server.port)
@ -114,6 +115,7 @@ class NetTest(unittest.TestCase):
self.assertEqual(server.reply.split(b'\n\n')[1], Path(f).read_bytes()) self.assertEqual(server.reply.split(b'\n\n')[1], Path(f).read_bytes())
server.stop() server.stop()
@patch.dict(os.environ, clear=True)
def test_download_file_retries_not_forever(self): def test_download_file_retries_not_forever(self):
"""The retry logic should eventually exit with an error.""" """The retry logic should eventually exit with an error."""
server = RetryServer(failures=5) server = RetryServer(failures=5)