1

I currently use Fast API GraphQL+ Strawberry with pytest to test graphql schema queries and mutations.

But when running multiple tests it sends me an error.

$ 'message': "'NoneType' object has no attribute 'send'",

My Python file for conf tests

import pytest
from src.graphql.db.session import get_session
from tests.graphql.db import overide_get_session
from fastapi.testclient import TestClient
from src.app import create_app


@pytest.fixture
def test_client_keep_alive():

    app = create_app()
    app.dependency_overrides[get_session] = overide_get_session
    client = TestClient(app)
    return client

My python file for tests

from tests.graphql.queries import get_users_query

class TestClass:

    def test_one_get_users(self,test_client_keep_alive):

        response = test_client_keep_alive.get(
            "/graphql",
            params = {
                "query": get_users_query,
            }
        )
        print(response.json())

    def test_two_get_users(self,test_client_keep_alive):

        response = test_client_keep_alive.get(
            "/graphql",
            params = {
                "query": get_users_query,
            }
        )
        print(response.json())
SYED FAISAL
  • 495
  • 5
  • 8

1 Answers1

0

Something in the code you are trying to test, calls a send() method from a object that does not exist. Try adding your code to the example, to better understand what's happening.

But from the information available, I would say that you probably need to mock that missing object.