Skip to content

Commit

Permalink
Merge pull request #106 from aio-libs/add-uvloop-to-the-tests
Browse files Browse the repository at this point in the history
Add uvloop to the test suite
  • Loading branch information
jettify authored Sep 9, 2016
2 parents bb1964f + 7b7f12c commit bf97044
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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
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 bf97044

Please sign in to comment.