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

fixture 'aiohttp_client' not found #26

Closed
eLvErDe opened this issue Apr 10, 2018 · 6 comments
Closed

fixture 'aiohttp_client' not found #26

eLvErDe opened this issue Apr 10, 2018 · 6 comments
Labels

Comments

@eLvErDe
Copy link

eLvErDe commented Apr 10, 2018

Hello,

I'm not able to run the unittest and I don't understand why. Here is what happens:

==================================== ERRORS ====================================
______________________ ERROR at setup of test_get_payload ______________________
file /tmp/aiohttp-jwt-0.1.1/tests/test_middleware.py, line 13
  async def test_get_payload(create_app, aiohttp_client, fake_payload, token):
      async def handler(request):
          assert request.get('payload') == fake_payload
          return web.json_response({'status': 'ok'})
      routes = (('/foo', handler),)
      client = await aiohttp_client(create_app(routes))
      response = await client.get('/foo', headers={
          'Authorization': 'Bearer {}'.format(token.decode('utf-8')),
      })
      assert response.status == 200
E       fixture 'aiohttp_client' not found
>       available fixtures: cache, capfd, caplog, capsys, capturelog, cov, create_app, doctest_namespace, event_loop, event_loop_process_pool, fake_payload, fast, loop, monkeypatch, pytestconfig, raw_test_server, record_xml_property, recwarn, secret, shorttmpdir, test_client, test_server, tmpdir, tmpdir_factory, token, unused_port, unused_tcp_port, unused_tcp_port_factory
>       use 'pytest --fixtures [testpath]' for help on them.

Thanks in advance for your support

@hzlmn
Copy link
Owner

hzlmn commented Apr 10, 2018

Hello, it is because this fixture available only in aiohttp >= 3.0. Previously it was named test_client. Seems like you ran tests against older version of aiohttp.

@hzlmn hzlmn added the question label Apr 10, 2018
@eLvErDe
Copy link
Author

eLvErDe commented Apr 10, 2018

Yes absolutely, 2.2.x.
Is there any way to detect this ?

@hzlmn
Copy link
Owner

hzlmn commented Apr 10, 2018

I guess, you can create proxy fixture like

@pytest.fixture
def aiohttp_client(test_client):
    return test_client

and add it to conftest file.
But i am wondering why do you want to run tests on older version? Also note that middleware works only with aiohttp >= 2.3.5

@eLvErDe
Copy link
Author

eLvErDe commented Apr 10, 2018

Well, basically I started rewriting some APIs at work using aiohttp and the easiest way for me to deploy libraries among executors machines is to create Debian package for them.
It's a standard practise to run unit tests at the end of the package building. We're using aiohttp 2.2.3 and I don't want to update this at the moment.

According to my first tests today, your middleware is working just fine with this version, but I'd feel relaxed if I could see all unittests running fine ;)

@hzlmn
Copy link
Owner

hzlmn commented Apr 11, 2018

Okay, I got your point. Could you please tell how did you build .deb package? I actually tested it locally with aiohttp 2.2.3 and with latests pytest-aiohttp it works fine.

@hzlmn
Copy link
Owner

hzlmn commented Jan 29, 2019

Closing due to inactivity. Feel free to reopen it if necessary.

@hzlmn hzlmn closed this as completed Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants