首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在graphene-django中运行特定的GraphQLTestCase测试?

如何在graphene-django中运行特定的GraphQLTestCase测试?
EN

Stack Overflow用户
提问于 2021-07-02 13:10:02
回答 1查看 85关注 0票数 0

导入json

从graphene_django.utils.testing导入GraphQLTestCase

从swapi.schema导入架构

类FirstTestCase(GraphQLTestCase):fixtures = 'app/fixtures/unittest.json‘GRAPHQL_SCHEMA = schema

代码语言:javascript
复制
def test_people_query(self):
    response = self.query(
        '''
            query{
              allPlanets {
                edges{
                  node{
                    id
                    name
                  }
                }
              }
            }
        ''',
    )
    
    self.assertResponseNoErrors(response)

    content = json.loads(response.content)
    self.assertEqual(len(content['data']['allPlanets']['edges']), 61)

def test_two(self):
    # Some test logic
    pass

我有上面的代码,我只需要运行test_two。我已经知道这个命令python manage.py会运行所有测试。请提前帮忙谢谢你

EN

回答 1

Stack Overflow用户

发布于 2021-07-03 00:55:47

您可以使用如下语法运行单个测试方法:

代码语言:javascript
复制
python manage.py test my_app.tests.FirstTestCase.test_two

(其中my_app.tests是包含FirstTestCase的文件的Python点分路径。)有关详细信息,请访问Django documentation for Running tests

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68219889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档