diff --git a/tests/__init__.py b/tests/__init__.py index 4c203bb93..7e02759ea 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -32,9 +32,9 @@ def setUp(self): start_url = None for method, url, path in self.expected_requests: start_url = start_url or url - content = open(path, encoding="utf-8").read() - response = responses.Response(method, url, body=content) - response.passthrough = self.online - rsps.add(response) + with open(path, encoding="utf-8") as f: + response = responses.Response(method, url, body=f.read()) + response.passthrough = self.online + rsps.add(response) self.harvester_class = self.scraper_class(url=start_url)