python - 如何为我自己的应用程序使用 cherrypy 测试工具?

标签 python testing cherrypy

我可以找到 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/

相关文章:

python - PyTorch |使用数据集 Omniglot 获取 "RuntimeError: Found dtype Long but expected Float"

python - DRF : Validate nested serializer data when creating, 但更新时没有

python - 如何返回不带引号的字符串 Python 3

ruby - 在测试永无止境的流程时,如何从测试中停止流程?

python - CherryPy 在基准测试中慢 60 倍,8 个请求线程与 7 个请求线程相比

python - tensorflow 值错误: Too many vaues to unpack (expected 2)

testing - 在 TestCafe 中可以注册 xhr 并用作模拟(自动模拟)

spring-boot - 如何浏览器测试模拟 API 调用的 Vue.js 应用程序?

python - 将 CherryPy 与路由调度一起使用

configuration-files - 樱桃皮 : Accessing Global config