问题描述
导入json
从graphene_django.utils.testing 导入GraphQLTestCase
从 swapi.schema 导入架构
类 FirstTestCase(GraphQLTestCase): 夹具 = ['app/fixtures/unittest.json'] GRAPHQL_SCHEMA = 架构
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 test 运行所有测试。请帮忙提前谢谢
解决方法
您可以使用以下语法运行单个测试方法:
python manage.py test my_app.tests.FirstTestCase.test_two
(其中 my_app.tests
是包含 FirstTestCase
的文件的 Python 虚线路径。)Django documentation for Running tests 中的更多信息。