Skip to content

Commit

Permalink
Fix ResourceWarnings in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 19, 2024
1 parent 6c5b538 commit ab5e93b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,15 @@ def test_write(self): # pylint: disable=R0201
content1 = StringIO("Iñtërnâtiônàližætiøn")
assert 20 == io.write(StringIO(), content1)
content1.seek(0)
assert 20 == io.write(TemporaryFile(), content1)
with TemporaryFile() as tf:
assert 20 == io.write(tf, content1)

content2 = io.IterStringIO(iter("Hello World"))
assert 12 == io.write(TemporaryFile(), content2, chunksize=2)
with TemporaryFile() as tf:
assert 12 == io.write(tf, content2, chunksize=2)

# pylint: disable=E1101
responses.add(responses.GET, url=url, body=body)
r = requests.get(url, stream=True) # pylint: disable=C0103
assert 55 == io.write(TemporaryFile(), r.iter_content)
with TemporaryFile() as tf:
assert 55 == io.write(tf, r.iter_content)

0 comments on commit ab5e93b

Please sign in to comment.