self._web_server.server_close()
def testFetch(self) -> None:
- paperdoorknob.fetch(f"http://localhost:{self._port()}", TIMEOUT)
- self.assertEqual(self._request_counter, 1)
- paperdoorknob.fetch(f"http://localhost:{self._port()}", TIMEOUT)
- self.assertEqual(self._request_counter, 2)
+ with requests.session() as s:
+ paperdoorknob.fetch(f"http://localhost:{self._port()}", s, TIMEOUT)
+ self.assertEqual(self._request_counter, 1)
+ paperdoorknob.fetch(f"http://localhost:{self._port()}", s, TIMEOUT)
+ self.assertEqual(self._request_counter, 2)
def testFetchErrors(self) -> None:
- with self.assertRaises(requests.HTTPError):
- paperdoorknob.fetch(
- f"http://localhost:{self._port()}/not_found", TIMEOUT)
- with self.assertRaises(requests.HTTPError):
- paperdoorknob.fetch(
- f"http://localhost:{self._port()}/server_error", TIMEOUT)
+ with requests.session() as s:
+ with self.assertRaises(requests.HTTPError):
+ paperdoorknob.fetch(
+ f"http://localhost:{self._port()}/not_found", s, TIMEOUT)
+ with self.assertRaises(requests.HTTPError):
+ paperdoorknob.fetch(
+ f"http://localhost:{self._port()}/server_error", s, TIMEOUT)
if __name__ == '__main__':