-
Notifications
You must be signed in to change notification settings - Fork 158
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
add support for "async with cursor_context()" #265
Open
thehesiod
wants to merge
41
commits into
aio-libs:master
Choose a base branch
from
thehesiod-forks:async_cursor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 27 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
f83c890
add support for "async with cursor_context()"
thehesiod c850e2b
fix pep warnings
thehesiod 0ffd312
pep
thehesiod 157c580
merge old style with new style
thehesiod e0d69bd
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod 0660956
add new testcase and remove unneeded statements
thehesiod 8af3e6d
pep
thehesiod fd42c6c
use init trick from asyncpg
thehesiod 4949621
bugfix
thehesiod bebe1b3
well that took awhile to figure out
thehesiod 857abfd
pep
thehesiod e8a78b2
fix for py3.4
thehesiod bfbd60e
revise unittests
thehesiod 623c368
arr
thehesiod 4770379
refactor to use _PoolConnectionContextManager
thehesiod 452e10b
remove unused code
thehesiod 5da64ed
pep
thehesiod 3897640
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod 375c6bf
simplify + update deps
thehesiod dabca4e
remove unused var
thehesiod cc05d18
attempt switching to the latest docker
thehesiod c8b506d
another attempt
thehesiod 1e964ff
revert docker client upgrade
thehesiod 1ca9b5f
revert docker client upgrade changes
thehesiod 2321a82
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod 0a57593
add back missing change
thehesiod a5cec12
revert as this was later refactored
thehesiod a30fa02
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod bdc39c3
add changes
thehesiod 945b8fa
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod dd94ae4
update from master
thehesiod 351bcd8
fix merge
thehesiod 60e9573
simplification
thehesiod 256f7b8
add missing import
thehesiod 02ca4e1
pep fix
thehesiod cbd93c5
integration fix
thehesiod 4e52944
more merge fixes
thehesiod f613762
PEP fix
thehesiod 3e4d0ba
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod 55b4b79
Merge remote-tracking branch 'aio-libs/master' into async_cursor
thehesiod 1133c6a
fix merge bug
thehesiod 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,11 +1,9 @@ | ||
import asyncio | ||
import pytest | ||
import aiopg | ||
import aiopg.sa | ||
from aiopg.sa import SAConnection | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_cursor_await(make_connection): | ||
conn = await make_connection() | ||
|
||
|
@@ -16,7 +14,6 @@ async def test_cursor_await(make_connection): | |
cursor.close() | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_connect_context_manager(loop, pg_params): | ||
async with aiopg.connect(loop=loop, **pg_params) as conn: | ||
cursor = await conn.cursor() | ||
|
@@ -27,7 +24,26 @@ async def test_connect_context_manager(loop, pg_params): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_pool_cursor_context_manager(loop, pg_params): | ||
async with aiopg.create_pool(loop=loop, **pg_params) as pool: | ||
async with pool.cursor() as cursor: | ||
await cursor.execute('SELECT 42') | ||
resp = await cursor.fetchone() | ||
assert resp == (42, ) | ||
assert cursor.closed | ||
assert pool.closed | ||
|
||
|
||
async def test_pool_cursor_await_context_manager(loop, pg_params): | ||
async with aiopg.create_pool(loop=loop, **pg_params) as pool: | ||
with (await pool.cursor()) as cursor: | ||
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. Should the 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. I believe this is tested in |
||
await cursor.execute('SELECT 42') | ||
resp = await cursor.fetchone() | ||
assert resp == (42, ) | ||
assert cursor.closed | ||
assert pool.closed | ||
|
||
|
||
async def test_connection_context_manager(make_connection): | ||
conn = await make_connection() | ||
assert not conn.closed | ||
|
@@ -40,7 +56,6 @@ async def test_connection_context_manager(make_connection): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_cursor_create_with_context_manager(make_connection): | ||
conn = await make_connection() | ||
|
||
|
@@ -53,7 +68,6 @@ async def test_cursor_create_with_context_manager(make_connection): | |
assert cursor.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_cursor_with_context_manager(make_connection): | ||
conn = await make_connection() | ||
cursor = await conn.cursor() | ||
|
@@ -66,7 +80,6 @@ async def test_cursor_with_context_manager(make_connection): | |
assert cursor.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_cursor_lightweight(make_connection): | ||
conn = await make_connection() | ||
cursor = await conn.cursor() | ||
|
@@ -78,7 +91,6 @@ async def test_cursor_lightweight(make_connection): | |
assert cursor.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_pool_context_manager(pg_params, loop): | ||
pool = await aiopg.create_pool(loop=loop, **pg_params) | ||
|
||
|
@@ -93,7 +105,6 @@ async def test_pool_context_manager(pg_params, loop): | |
assert pool.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_create_pool_context_manager(pg_params, loop): | ||
async with aiopg.create_pool(loop=loop, **pg_params) as pool: | ||
async with pool.acquire() as conn: | ||
|
@@ -107,7 +118,6 @@ async def test_create_pool_context_manager(pg_params, loop): | |
assert pool.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_cursor_aiter(make_connection): | ||
result = [] | ||
conn = await make_connection() | ||
|
@@ -122,7 +132,6 @@ async def test_cursor_aiter(make_connection): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_engine_context_manager(pg_params, loop): | ||
engine = await aiopg.sa.create_engine(loop=loop, **pg_params) | ||
async with engine: | ||
|
@@ -132,15 +141,13 @@ async def test_engine_context_manager(pg_params, loop): | |
assert engine.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_create_engine_context_manager(pg_params, loop): | ||
async with aiopg.sa.create_engine(loop=loop, **pg_params) as engine: | ||
async with engine.acquire() as conn: | ||
assert isinstance(conn, SAConnection) | ||
assert engine.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_result_proxy_aiter(pg_params, loop): | ||
sql = 'SELECT generate_series(1, 5);' | ||
result = [] | ||
|
@@ -154,7 +161,6 @@ async def test_result_proxy_aiter(pg_params, loop): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_transaction_context_manager(pg_params, loop): | ||
sql = 'SELECT generate_series(1, 5);' | ||
result = [] | ||
|
@@ -181,7 +187,6 @@ async def test_transaction_context_manager(pg_params, loop): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_transaction_context_manager_error(pg_params, loop): | ||
async with aiopg.sa.create_engine(loop=loop, **pg_params) as engine: | ||
async with engine.acquire() as conn: | ||
|
@@ -194,7 +199,6 @@ async def test_transaction_context_manager_error(pg_params, loop): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_transaction_context_manager_commit_once(pg_params, loop): | ||
async with aiopg.sa.create_engine(loop=loop, **pg_params) as engine: | ||
async with engine.acquire() as conn: | ||
|
@@ -214,7 +218,6 @@ async def test_transaction_context_manager_commit_once(pg_params, loop): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_transaction_context_manager_nested_commit(pg_params, loop): | ||
sql = 'SELECT generate_series(1, 5);' | ||
result = [] | ||
|
@@ -244,7 +247,6 @@ async def test_transaction_context_manager_nested_commit(pg_params, loop): | |
assert conn.closed | ||
|
||
|
||
@asyncio.coroutine | ||
async def test_sa_connection_execute(pg_params, loop): | ||
sql = 'SELECT generate_series(1, 5);' | ||
result = [] | ||
|
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.
Why do you need this property?
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.
used here https://github.com/aio-libs/aiopg/pull/265/files#diff-222246bbd6dde09cb363ee2c57a67887R246