Skip to content

Conversation

@MichalMazurek
Copy link
Contributor

TypeEror 'async for' received an object from __aiter__ that does not implement anext: generator

Link to the issue: #92

TypeEror  'async for' received an object from `__aiter__` that does not implement __anext__: generator
@gabor-boros
Copy link
Member

@MichalMazurek, thank you for your contributions! Could you please write some test for the change? (For example based on what you wrote in issue/10.

We are trying to increase our coverage and make sure not to break anything in the future. It would be a huge help.

@MichalMazurek
Copy link
Contributor Author

Sure I will.

@MichalMazurek
Copy link
Contributor Author

Do you know a way to separate tests for 2.7 and 3.4? The legacies are complaining about async def structure. I added them to allow_failure, but the travis still fails the build. There is a separate test with @coroutine syntax.

@gabor-boros
Copy link
Member

@MichalMazurek Yes I know, you can use skipif (https://docs.pytest.org/en/latest/skipping.html#id1). The example there is especially for this situation. I would suggest not to allow failures on those python versions.

@MichalMazurek
Copy link
Contributor Author

@gabor-boros Oh I tried, and actually did it, but when pytest is importing them then it stops because of SyntaxError... It would have to be done on travis script level or in Makefile.

@gabor-boros
Copy link
Member

Hm, What you could do is to create a file where you put the async io related tests (ex: asyncio_tests.py)

async def something():
    pass

Then in the actual test tests/integration/test_asyncio.py you could write:

@pytest.mark.asyncio
@pytest.mark.integration
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher")
def test_flow():
    """
    Test the flow for 3.6 and up, async generators are
    not supported in 3.5.
    """

    from asyncio_tests import something
    something()

To be honest I never worked with async, but I think you can avoid the syntax error if you are import the async function only when the test will be not skipped.

@grandquista, What do you think, how hacky is that? I know it is ugly but I can not think about a better solution right now.

@asakatida
Copy link

There should be a top level settings file that pytest has for limiting tests run. The coroutine decorator syntax should still be working in all versions, so that may be a better first pass. I’ll look up the pytest configuration

Sent with GitHawk

@asakatida
Copy link

There should be a top level settings file that pytest has for limiting tests run. The coroutine decorator syntax should still be working in all versions, so that may be a better first pass. I’ll look up the pytest configuration https://docs.pytest.org/en/latest/pythonpath.html#test-modules-conftest-py-files-inside-packages

Sent with GitHawk

@MichalMazurek
Copy link
Contributor Author

Maybe TRAVIS_PYTHON_VERSION could be used to check if python version is lower than 3.4 and then add --ignore=tests/integration/test_asyncio.py and for 2.7 --ignore=tests/integration/test_asyncio.py --ignore=tests/integration/test_asyncio_coroutine.py. What do you reckon?

@gabor-boros
Copy link
Member

gabor-boros commented Mar 4, 2019

@grandquista, @MichalMazurek what do you think about ‘pytest_ignore_collect’ hook? As I read this would be the cleanest solution

@asakatida
Copy link

pytest_collect_file seems to have cleaner documentation. There’s some weird language about first result early exits in the other. I’m also good with using the environment to set the command. It could be ignore by default and explicit extra includes so that running locally wouldn’t be surprising

Sent with GitHawk

@MichalMazurek
Copy link
Contributor Author

Hi Guys, I will come back to you tomorrow with it, I had a busy day :)

@MichalMazurek
Copy link
Contributor Author

So this does the trick, @grandquista thanks for the tip!

# conftest.py
import sys

collect_ignore = []
if sys.version_info < (3, 4):
    collect_ignore += ["integration/test_asyncio.py", "integration/test_asyncio_coroutine.py"]
elif sys.version_info < (3, 6):
    collect_ignore.append("integration/test_asyncio.py")

@gabor-boros gabor-boros merged commit d7e7054 into rethinkdb:master Mar 6, 2019
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

Successfully merging this pull request may close these issues.

3 participants