-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement async context manager support * Fix tests * Update CHANGES
- Loading branch information
Showing
5 changed files
with
48 additions
and
6 deletions.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import sys | ||
|
||
|
||
def pytest_ignore_collect(path, config): | ||
if 'py35' in str(path): | ||
if sys.version_info < (3, 5, 0): | ||
return True |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from async_timeout import timeout | ||
|
||
|
||
async def test_async_timeout(loop): | ||
with pytest.raises(asyncio.TimeoutError): | ||
async with timeout(0.01, loop=loop) as cm: | ||
await asyncio.sleep(10, loop=loop) | ||
assert cm.expired | ||
|
||
|
||
async def test_async_no_timeout(loop): | ||
async with timeout(1, loop=loop) as cm: | ||
await asyncio.sleep(0, loop=loop) | ||
assert not cm.expired |