Skip to content

Commit

Permalink
Re-introduce use of a file open contextmanager during unit test data …
Browse files Browse the repository at this point in the history
…loading to avoid noisy ResourceWarning output when running unit tests with python -m unittest (#609)

Fixes #608
  • Loading branch information
jayaddison committed Sep 30, 2022
1 parent 07a5549 commit 442a035
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/__init__.py
Expand Up @@ -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)

0 comments on commit 442a035

Please sign in to comment.