diff --git a/html5lib/tests/test_stream.py b/html5lib/tests/test_stream.py
index efe9b472..346837bc 100644
--- a/html5lib/tests/test_stream.py
+++ b/html5lib/tests/test_stream.py
@@ -212,9 +212,9 @@ def makefile(self, _mode, _bufsize=None):
source = http_client.HTTPResponse(FakeSocket())
source.begin()
- wrapped = urllib.response.addinfourl(source, source.msg, "http://example.com")
- stream = HTMLInputStream(wrapped)
- assert stream.charsUntil(" ") == "Text"
+ with urllib.response.addinfourl(source, source.msg, "http://example.com") as wrapped:
+ stream = HTMLInputStream(wrapped)
+ assert stream.charsUntil(" ") == "Text"
@pytest.mark.parametrize("inp,num",