Skip to content
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

Latest version causing test failures #52

Closed
vangheem opened this issue May 29, 2017 · 11 comments
Closed

Latest version causing test failures #52

vangheem opened this issue May 29, 2017 · 11 comments

Comments

@vangheem
Copy link

Getting:

E           RuntimeError: Task <Task pending coro=<pytest_fixture_setup.<locals>.wrapper.<locals>.setup() running at /home/travis/build/plone/guillotina/eggs/pytest_asyncio-0.6.0-py3.6.egg/pytest_asyncio/plugin.py:120> cb=[_run_until_complete_cb() at /opt/python/3.6-dev/lib/python3.6/asyncio/base_events.py:176]> got Future <_GatheringFuture pending> attached to a different loop

on many of my tests now.

Downgrading to 0.5.0 works. Is there something I'm doing wrong in my tests?

@Tinche
Copy link
Member

Tinche commented May 29, 2017

Not necessarily, might be a bug in our fixture handling code.

Can you get me a minimal example?

@vangheem
Copy link
Author

I'll see if I have time to do that later. The package the test failures started in is open source though.

Here is failure output: https://travis-ci.org/plone/guillotina/builds/237114876

and here is the test server being created: https://github.com/plone/guillotina/blob/master/guillotina/tests/conftest.py#L198

But that's a lot of code to digest and not sure there is anything obvious there.

I'll see what I can do when I have some more time.

@Tinche
Copy link
Member

Tinche commented May 29, 2017

As far as I can see, your tests are actually pytest-aiohttp, not pytest-asyncio tests. You have async def tests without the @pytest.mark.asyncio marker.

I see you have some async def fixtures too, which weren't supported in pytest-asyncio until 0.6. So these were being picked up by pytest-aiohttp too.

So I'm guessing now pytest-asyncio and pytest-aiohttp are in conflict.

@spumer
Copy link

spumer commented Jun 15, 2017

I have failure on 0.6.0 too, but due setup event_loop fixture.

fixturedef = <FixtureDef name='event_loop' scope='function' baseid='' >
request = <SubRequest 'event_loop' for <Function 'test_get_gen_products'>>
... # here a lot of code
        if fixturedef.argname == "event_loop" and 'asyncio' in request.keywords:
            loop = outcome.get_result()
            for kw in _markers_2_fixtures.keys():
                if kw not in request.keywords:
                    continue
                policy = asyncio.get_event_loop_policy()
>               old_loop = policy.get_event_loop()


    def get_event_loop(self):
        """Get the event loop.
    
            This may be None or an instance of EventLoop.
            """
        if (self._local._loop is None and
            not self._local._set_called and
            isinstance(threading.current_thread(), threading._MainThread)):
            self.set_event_loop(self.new_event_loop())
        if self._local._loop is None:
            raise RuntimeError('There is no current event loop in thread %r.'
>                              % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

In previous version asyncio-pytest did not require initialized old loop. But now...

@Tinche
Copy link
Member

Tinche commented Jun 15, 2017

Do you have pytest-aiohttp installed too?

@spumer
Copy link

spumer commented Jun 15, 2017

@Tinche yes, pytest-aiohttp==0.1.3

@Tinche
Copy link
Member

Tinche commented Jun 15, 2017

Unfortunately pytest-asyncio isn't compatible with pytest-aiohttp any longer - you're seeing the conflicts.

@spumer
Copy link

spumer commented Jun 15, 2017

Putting this code into conftest.py solve the problem

import asyncio
policy = asyncio.get_event_loop_policy()
policy.set_event_loop(policy.new_event_loop())

But where is real problem placed? pytest-aiohttp or pytest-asyncio?

@spumer
Copy link

spumer commented Jun 26, 2017

The main fail when pytest-aiohttp installed - parameterized async fixtures did not work

@jstephenson
Copy link

Shame that they aren't able to coexist presently — I have a mix of code, some of which uses aiohttp and a good bit which doesn't. It would be preferred to use pytest-asyncio for the latter.

Nuking the default loop in aiohttp: https://github.com/aio-libs/aiohttp/blob/4ecb6339ddb60ad732e8a79a32ce75c10ec8546d/aiohttp/pytest_plugin.py#L144

@Zac-HD
Copy link
Member

Zac-HD commented Dec 10, 2018

Closed by #52.

@Zac-HD Zac-HD closed this as completed Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants