plone集成测试层的无痛设置

plone.testlayers的Python项目详细描述


简介

plone.testlayers应该为plone设置测试层 集成测试快速、无痛苦。它的主要功能是makeTestLayer 将方便地生成一个测试层,它将加载您的包zcml 然后安装它们,应用GenericSetupprofile并帮助您设置示例 快速测试的内容。

用法

要使用plone.testlayers,通常需要为 你的包裹,有点像:

from Products.PloneTestCase import PloneTestCase as ptc
from plone.testlayers import makeTestLayer

def create(portal):
    """ create sample content for test runs """
    portal.invokeFactory('File', 'foo', title='foo', file='foo bar')

def destroy(portal):
    """ clean up sample content for test runs """
    portal.manage_delObjects(ids='foo')

ptc.setupPloneSite()
FooLayer = makeTestLayer(packages=('collective.foo', 'collective.bar'),
    profile='collective.foo:default', create=create, destroy=destroy)

class FooTestCase(ptc.PloneTestCase):
    """ base class for integration tests """
    layer = FooLayer

有了它,您现在可以设置您的单独测试用例,如:

from unittest import defaultTestLoader
from collective.foo.tests.base import FooTestCase

class FooTests(FooTestCase):

    def testFoo(self):
        # the 'foo' object set up in the layer should already exist
        self.failUnless(self.portal['foo'])

def test_suite():
    return defaultTestLoader.loadTestsFromName(__name__)

变更日志

1.0a3-2009年4月24日发布

  • 添加对生成多个测试层的支持。 [威驰]

1.0a2-2009年4月23日发布

  • 使用MANIFEST.in修复源分发。 [威驰]

1.0a1-2009年4月23日发布

  • 初次发布。 [威驰]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android操作共享首选项更新值   java是否可以在单个参数化测试之前执行一次方法?   Java创建临时文件   java字符串已定义但未解析?   java JOptionPane。showConfirmDialog返回int 01而不是字符串YN   java Unitronics OPC Server>JIException访问被拒绝   gzip使用Java组合压缩的gzip文本文件   java在灵活的环境中部署bigtable helloworld不起作用   aspectJ中的java字段读字段写访问   java Hibernate让它映射   找不到媒体类型为application/json、类型为class java的MessageBodyWriter。util。ArrayList   java在SpringMVC中将图像上传到服务器并在mysql数据库中存储引用   如何用Java制作自己的解释器?   java在移动应用程序上使用appium滚动并查找页面中的元素   java无法在重新启动springjdbc、CommonDBCP、tomcat时连接到数据库   java捕获非法argumentException的最佳方法是什么   设计模式避免Java代码重复的良好实践   Java ResourceBundle是如何实现的。getBundle加载属性文件?   java远程访问OpenMQ