Skip to content

Commit

Permalink
add uvloop to the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
jettify committed Sep 8, 2016
1 parent bb1964f commit 889f8c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ before_script:
- "mysql -e 'DROP DATABASE IF EXISTS test_pymysql2; create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"

install:
- if python -c "import sys; sys.exit(sys.version_info < (3,5))"; then
pip install uvloop;
fi
- pip install -Ur requirements-dev.txt
- pip install .
- pip install coveralls

script:
- make cov
Expand Down
20 changes: 19 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@
import pytest


PY_35 = sys.version_info >= (3, 5)
if PY_35:
import uvloop
else:
uvloop = None


def pytest_generate_tests(metafunc):
if 'loop_type' in metafunc.fixturenames:
loop_type = ['asyncio', 'uvloop'] if uvloop else ['asyncio']
metafunc.parametrize("loop_type", loop_type)


@pytest.yield_fixture
def loop(request):
def loop(request, loop_type):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(None)

if uvloop and loop_type == 'uvloop':
loop = uvloop.new_event_loop()
else:
loop = asyncio.new_event_loop()

yield loop

if not loop._closed:
Expand Down

0 comments on commit 889f8c5

Please sign in to comment.