开发者

How to use cherrypy test harness for my own application?

I can find the way to call the test harness, 开发者_运维问答but I can't figure out how to write a simple test case. Thanks.


Alright I got a simple test case working, but since we are using a non-standard routing method I discovered that I had to reinitialize the global cherrypy configuration explicitly for each test case (after the testharness reinitializes it incorrectly). Here it is:

""" test that the test harness is working. """

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() fixes up the cherrypy "tree" object to work after the testharness breaks it. This test case works for me with the TestHarness as described in the link given in the question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜