我可以找到 way to call the test harness ,但我不知道如何编写一个简单的测试用例。谢谢。
最佳答案
好吧,我得到了一个简单的测试用例,但由于我们使用的是非标准路由方法,我发现我必须为每个测试用例明确地重新初始化全局 cherrypy 配置(在测试工具重新初始化它不正确之后)。在这里:
""" 测试测试工具是否正常工作。 """
import test_assignment_web
from cherrypy.test import helper
import cherrypy
class testTestHarness(helper.CPWebCase):
def setUp(self):
# fix up the cherrypy tree...
test_assignment_web.setUp()
def testTestPage(self):
path = "/test"
self.getPage(path)
self.assertStatus('200 OK')
test_assignment_web.setUp() 修复了 cherrypy“树”对象,使其在测试工具破坏后继续工作。如问题中给出的链接中所述,此测试用例适用于 TestHarness。
关于python - 如何为我自己的应用程序使用 cherrypy 测试工具?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7417701/