-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ResourceWarning unclosed socket and re-enable and fix tornado tests #801
Merged
graingert
merged 28 commits into
kevin1024:master
from
graingert:fix-resource-warning-2
Jan 23, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f414435
Fix ResourceWarning unclosed socket
17c78bf
Merge branch 'master' of github.com:kevin1024/vcrpy into fix-resource…
graingert 556fd01
enable filterwarnings=error
graingert fa789e9
fix a KeyError
graingert bddec2e
use socketserver.ThreadingTCPServer as a contextmanager
graingert 3919cb2
remember to close the VCRHTTPSConnection
graingert f075c8b
close aiohttp session on errors
graingert 895ae20
use asyncio.run to run coroutines
graingert 97de8a0
ignore warning from dateutil
graingert 73d11e8
fix httpx resource warnings
graingert cf76592
remove redundant contextlib import
graingert 356ff41
fix sync do_request().stream
graingert 80614db
fix resource warning due to pytest-asyncio
graingert 5cff354
Revert "fix a KeyError"
graingert d76c243
Revert "Fix ResourceWarning unclosed socket"
graingert d39c26b
remember to close removed connections
graingert 8e13af2
use context manager for requests.Session
graingert cc4d03c
close unremoved connections (pool already removed the connection)
graingert ee6e790
Merge branch 'master' into fix-resource-warning-2
graingert 5104b1f
Merge branch 'master' of github.com:kevin1024/vcrpy into fix-resource…
graingert 666686b
restore pytest-tornado
graingert a093fb1
add new deprecation warnings for tornado tests
graingert c6667ac
restore scheme fixture for tests
graingert db1f5b0
tornado 6 changes raise_error behaviour
graingert 6d7a842
fix test_tornado_exception_can_be_caught RuntimeError: generator rais…
graingert b7f6c2f
mark tornado tests as online
graingert 42b4a5d
move off of mockbin on tornado tests also
graingert 784b2dc
tornado test_redirects is no longer an online test
graingert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import contextlib | ||
import logging | ||
import urllib.parse | ||
|
||
|
@@ -14,10 +13,10 @@ | |
|
||
|
||
def run_in_loop(fn): | ||
with contextlib.closing(asyncio.new_event_loop()) as loop: | ||
asyncio.set_event_loop(loop) | ||
task = loop.create_task(fn(loop)) | ||
return loop.run_until_complete(task) | ||
async def wrapper(): | ||
return await fn(asyncio.get_running_loop()) | ||
|
||
return asyncio.run(wrapper()) | ||
|
||
|
||
def request(method, url, output="text", **kwargs): | ||
|
@@ -260,6 +259,12 @@ def test_aiohttp_test_client_json(aiohttp_client, tmpdir): | |
assert cassette.play_count == 1 | ||
|
||
|
||
def test_cleanup_from_pytest_asyncio(): | ||
# work around https://github.com/pytest-dev/pytest-asyncio/issues/724 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
asyncio.get_event_loop().close() | ||
asyncio.set_event_loop(None) | ||
|
||
|
||
@pytest.mark.online | ||
def test_redirect(tmpdir, httpbin): | ||
url = httpbin.url + "/redirect/2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'll fix these deprecation warnings in a followup PR
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!