-
Notifications
You must be signed in to change notification settings - Fork 193
Implement HTTP20Adapter.close to close connections #307
base: development
Are you sure you want to change the base?
Conversation
ed08296
to
cc905d5
Compare
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, so this looks reasonable! I have made some suggestions for alternative testing approaches.
test/test_hyper.py
Outdated
with requests.Session() as s: | ||
a = HTTP20Adapter() | ||
s.mount('https://http2bin.org', a) | ||
s.get('https://http2bin.org/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly recommend avoiding making real web requests in this test module (even if the rest of them do).
I recommend mocking out some of the lower-level functions. It's probably enough to mock out the send
method of the adapter and the HTTPConnection
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the test to just mount the adapter without making a request. It raises the same error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @allanlei, it looks like pytest doesn't think this test case is actually hitting line 163 (connection._conn.close()
) in contrib.py. Until that's properly triggered, Travis will continue returning a failure.
Without initiating a request, I'm not sure if self.connections.values()
will be populated. If that's the case, the for loop will never execute.
So I think @nateprewitt's deleted comment is right: I think we need to initiate a HTTP/2 request here. Rather than use http2bin you may need to write a socket-level test as is done elsewhere in the code. |
Not deleted, just hiding on the last "requested changes" comment thread 😉 |
Fixes #306