导入json
从graphene_django.utils.testing导入GraphQLTestCase
从swapi.schema导入架构
类FirstTestCase(GraphQLTestCase):fixtures = 'app/fixtures/unittest.json‘GRAPHQL_SCHEMA = 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会运行所有测试。请提前帮忙谢谢你
发布于 2021-07-03 00:55:47
您可以使用如下语法运行单个测试方法:
python manage.py test my_app.tests.FirstTestCase.test_two(其中my_app.tests是包含FirstTestCase的文件的Python点分路径。)有关详细信息,请访问Django documentation for Running tests。
https://stackoverflow.com/questions/68219889
复制相似问题