No autocomplete for flask tests

Hi!

I am currently writing tests for a flask app for the first time, and could greatly profit from autocompletion since I don't know which methods and attributes are available for a given object, however, there are no autocomplete suggestions for the flask test_client. I am using Pycharm Professional 2020.01 so there should be flask support. This is my code, if I type 'client.' I would usually expect to see suggestions, but there aren't any. Could someone give me a hint on why this could be?

import pytest
from flask import url_for
from app import app


@pytest.fixture
def client():
    app_context = app.test_request_context()
    app_context.push()
    client = app.test_client()
    return client


def test_successful_login(client):
    # Login
    response = client.post(url_for('login'), content_type='multipart/form-data', data={
        'username': 'testuser',
        'password': 'testpassword'
    })

    assert response.status_code == 302, f"Response should have been a redirect (302) but was {response.status_code}!"
    assert 'auth_tkt' in client.cookie_jar, f"No auth_tkt cookie found!"
0
2 comments

Is there no code completion at all or something specific is missing?

Have you selected pytest as your default test runner in File | Settings | Tools | Python Integrated Tools?

0

Thank you, setting pytest as my default test runner solved it! Before, it seems that pycharm didn't keep track of the type of the client object and treated it like any parameter passed into a function.

0

Please sign in to leave a comment.