mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix unclosed resource warnings in fetch backend tests
This commit is contained in:
parent
d8d63646f4
commit
60555c1389
@ -102,6 +102,12 @@ class FakeResponse:
|
||||
def close(self):
|
||||
self._data.close()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *a):
|
||||
self._data.close()
|
||||
|
||||
|
||||
def shutdown_browser(bref):
|
||||
br = bref()
|
||||
|
@ -109,10 +109,10 @@ class TestFetchBackend(unittest.TestCase):
|
||||
req = Request(url, headers=headers)
|
||||
else:
|
||||
req = url
|
||||
res = br.open(req, data=data, timeout=timeout)
|
||||
raw = res.read()
|
||||
ans = json.loads(raw)
|
||||
ans['final_url'] = res.geturl()
|
||||
with br.open(req, data=data, timeout=timeout) as res:
|
||||
raw = res.read()
|
||||
ans = json.loads(raw)
|
||||
ans['final_url'] = res.geturl()
|
||||
return ans
|
||||
|
||||
def test_with_timeout(no_response=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user