Flask 测试Graphql(石墨烯)模式

Flask 测试Graphql(石墨烯)模式,flask,graphql,graphene-python,Flask,Graphql,Graphene Python,我一直在寻找关于如何测试graphql(Graphene,实际上是因为我有一个python flask应用程序)模式是否正确加载的指导。我安装的Graphene版本都不支持示例中显示的内容,所以我觉得我在这里不知所措 from graphene.test import Client def test_hey(): client = Client(my_schema) executed = client.execute('''{ hey }''', context_value={

我一直在寻找关于如何测试graphql(Graphene,实际上是因为我有一个python flask应用程序)模式是否正确加载的指导。我安装的Graphene版本都不支持示例中显示的内容,所以我觉得我在这里不知所措

from graphene.test import Client

def test_hey():
    client = Client(my_schema)
    executed = client.execute('''{ hey }''', context_value={'user': 'Peter'})
    assert executed == {
        'data': {
             'hey': 'hello Peter!'
        }
    }

我得到的错误:
namererror:global name'Client'未定义
表明
Client
在石墨烯领域中不存在。有人遇到过这个问题吗?

您需要确保在测试范围内有可用的
石墨烯


目前,
graphene.test.Client
已经存在。

谢谢你,我觉得自己很傻。您的解决方案有效:)