【问题标题】:Test Graphql (Graphene) Schema测试 Graphql(石墨烯)架构
【发布时间】:2018-03-11 22:13:46
【问题描述】:

我一直在查看 https://media.readthedocs.org/pdf/graphene-python/latest/graphene-python.pdf 以获取有关如何测试我的 graphql(石墨烯,真的是因为我有一个 python 烧瓶应用程序)架构正确加载的指导。我安装的石墨烯版本都不支持示例显示的内容,所以我觉得我在这里不知所措。

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!'
        }
    }

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

【问题讨论】:

    标签: flask graphql graphene-python


    【解决方案1】:

    您需要确保在您的测试范围内有graphene。

    在此time,graphene.test.Client 存在。

    【讨论】:

    • 谢谢你——我觉得很傻。您的解决方案有效:)
    猜你喜欢
    • 2017-05-11
    • 2018-01-11
    • 2017-05-13
    • 2020-01-20
    • 2020-07-27
    • 2020-09-19
    • 2018-03-22
    • 2019-08-26
    • 2022-01-24
    相关资源
    最近更新 更多