Skip to content

Conversation

polosaty
Copy link

@polosaty polosaty commented Sep 9, 2022

I tried to download the examples/miniapps/fastapi.
After installing the dependencies, I ran the tests:
py.test giphynavigator/tests.py --cov=giphynavigator

And got errors:

py.test giphynavigator/tests.py --cov=giphynavigator
============================================================================================================================= test session starts ==============================================================================================================================
platform linux -- Python 3.10.7, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/mg/ws/lang_exp/python/python-dependency-injector
plugins: anyio-3.6.1, cov-3.0.0, asyncio-0.19.0
asyncio: mode=strict
collected 3 items                                                                                                                                                                                                                                                              

giphynavigator/tests.py FFF                                                                                                                                                                                                                                              [100%]

=================================================================================================================================== FAILURES ===================================================================================================================================
__________________________________________________________________________________________________________________________________ test_index __________________________________________________________________________________________________________________________________

client = <async_generator object client at 0x7fbe5e2c36c0>

    @pytest.mark.asyncio
    async def test_index(client):
        giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
        giphy_client_mock.search.return_value = {
            "data": [
                {"url": "https://giphy.com/gif1.gif"},
                {"url": "https://giphy.com/gif2.gif"},
            ],
        }
    
        with app.container.giphy_client.override(giphy_client_mock):
>           response = await client.get(
                "/",
                params={
                    "query": "test",
                    "limit": 10,
                },
            )
E           AttributeError: 'async_generator' object has no attribute 'get'

giphynavigator/tests.py:31: AttributeError
....
=========================================================================================================================== short test summary info ============================================================================================================================
FAILED giphynavigator/tests.py::test_index - AttributeError: 'async_generator' object has no attribute 'get'
FAILED giphynavigator/tests.py::test_index_no_data - AttributeError: 'async_generator' object has no attribute 'get'
FAILED giphynavigator/tests.py::test_index_default_params - AttributeError: 'async_generator' object has no attribute 'get'
============================================================================================================================== 3 failed in 0.55s ===============================================================================================================================

So here's a fix for this problem.

@ZipFile
Copy link
Contributor

ZipFile commented Dec 8, 2024

Hey, thanks for PR. This issue was present in pretty much every asyncio example we have, so this change was incorporated as part of #838 with fixes for other miniapp examples.

@ZipFile ZipFile closed this Dec 8, 2024
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.

2 participants