johnnoone / pytest-curio

Launch pytest with curio
Apache License 2.0
10 stars 6 forks source link

Error with py.test 3.0.3: 'Kernel' object has no attribute 'add_task' #1

Closed scribu closed 4 years ago

scribu commented 8 years ago
$ pip freeze | grep pytest
pytest==3.0.3
pytest-curio==0.1.0
$ cat example_test.py
import pytest

@pytest.mark.curio
async def test_some_curio_code():
    res = await library.do_something()
    assert b'expected result' == res
$ py.test example_test.py
====================================================== test session starts =======================================================
platform darwin -- Python 3.5.1, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /Users/scribu/git/curio-http, inifile:
plugins: curio-0.1.0
collected 1 items

example_test.py F

============================================================ FAILURES ============================================================
______________________________________________________ test_some_curio_code ______________________________________________________

pyfuncitem = <Function 'test_some_curio_code'>

    @pytest.mark.tryfirst
    def pytest_pyfunc_call(pyfuncitem):
        """
        Run curio marked test functions in a kernel instead of a normal
        function call.
        """
        if 'curio' in pyfuncitem.keywords:
            kernel = pyfuncitem.funcargs['kernel']
            funcargs = pyfuncitem.funcargs
            testargs = {arg: funcargs[arg]
                        for arg in pyfuncitem._fixtureinfo.argnames}
            fut = pyfuncitem.obj(**testargs)
>           task = kernel.add_task(fut)
E           AttributeError: 'Kernel' object has no attribute 'add_task'

../../.virtualenvs/curio-http/lib/python3.5/site-packages/pytest_curio/plugin.py:33: AttributeError
==================================================== 1 failed in 0.03 seconds ====================================================
sys:1: RuntimeWarning: coroutine 'test_some_curio_code' was never awaited
njsmith commented 7 years ago

Just ran into this as well... fix in #2

geronimo-iia commented 4 years ago

Hello, the last release (1.0.1 ) work with latest version of curio and fix this issue.