Skip to content

Commit

Permalink
Support python 3.7 and 3.8 in tests and travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszCzubak committed May 28, 2020
1 parent f9b86aa commit 95aeac5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ language: python

python:
- 3.6
- 3.7
- 3.8

env:
matrix:
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
uvloop = None


@pytest.fixture
def disable_gc():
gc.disable()
yield
gc.enable()


@pytest.fixture(scope='session')
def unused_port():
def f():
Expand Down
37 changes: 20 additions & 17 deletions tests/test_async_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def test_create_pool_deprecations(mysql_params, loop):
warnings.simplefilter("always")
async with pool.get() as conn:
pass
assert issubclass(w[-1].category, DeprecationWarning)
assert issubclass(w[0].category, DeprecationWarning)
assert conn.closed

async with create_pool(loop=loop, **mysql_params) as pool:
Expand All @@ -146,14 +146,15 @@ async def test_create_pool_deprecations(mysql_params, loop):
@pytest.mark.run_loop
async def test_sa_connection(table, mysql_params, loop):
async with sa.create_engine(loop=loop, **mysql_params) as engine:
connection = await engine.acquire()
assert not connection.closed
async with connection:
ret = []
async for i in connection.execute(tbl.select()):
ret.append(i)
conn = await engine.acquire()
assert not conn.closed
async with conn:
async with conn.execute(tbl.select()) as cursor:
ret = []
async for i in cursor:
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret
assert connection.closed
assert conn.closed


@pytest.mark.run_loop
Expand Down Expand Up @@ -194,21 +195,23 @@ async def test_sa_transaction_rollback(loop, mysql_params, table):
async def test_create_engine(loop, mysql_params, table):
async with sa.create_engine(loop=loop, **mysql_params) as engine:
async with engine.acquire() as conn:
ret = []
async for i in conn.execute(tbl.select()):
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret
async with conn.execute(tbl.select()) as cursor:
ret = []
async for i in cursor:
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret


@pytest.mark.run_loop
async def test_engine(loop, mysql_params, table):
engine = await sa.create_engine(loop=loop, **mysql_params)
async with engine:
async with engine.acquire() as conn:
ret = []
async for i in conn.execute(tbl.select()):
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret
async with conn.execute(tbl.select()) as cursor:
ret = []
async for i in cursor:
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret


@pytest.mark.run_loop
Expand All @@ -218,7 +221,7 @@ async def test_transaction_context_manager(loop, mysql_params, table):
async with conn.begin() as tr:
async with conn.execute(tbl.select()) as cursor:
ret = []
async for i in conn.execute(tbl.select()):
async for i in cursor:
ret.append(i)
assert [(1, 'a'), (2, 'b'), (3, 'c')] == ret
assert cursor.closed
Expand Down
1 change: 1 addition & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ async def test_connection_double_ensure_closed(connection_creator):


@pytest.mark.run_loop
@pytest.mark.usefixtures("disable_gc")
async def test___del__(connection_creator):
conn = await connection_creator()
with pytest.warns(ResourceWarning):
Expand Down

0 comments on commit 95aeac5

Please sign in to comment.