openerp unittesting工具包
itsbroken的Python项目详细描述
它可以帮助您为损坏的openerp modules编写单元测试,因为 openerps在测试功能方面没有太多的功能。如果你觉得奇怪 类似于Tryton测试用例,不要 困惑,这项工作的灵感来自于尝试测试。
大师级
开发
许可证tl;dr;
如果要发布使用的模块,此程序将附带一个 AGPL许可证。
如果你想在一个你不想做的模块中使用这个程序 公开,您应该满足以下条件:
- You have tweeted atleast once with the #sorryopenerp tag (Frequent bugs in Open ERP will push you in the right direction)
- You have visited the Tryton website atleast once.
- You believe that code without test is broken code (like Hollywood is incomplete without Julia Roberts)
- You do not use OpenERP or any modules with the “OpenERP AGPL + Private Use License”
许可证的详细版本可以在许可证文件中看到。
为什么这个执照乱七八糟?
虽然我们百分之百地致力于开源(另请参阅我们的常见问题解答),但我们理解 最终用户有时可能需要使用私有软件。为了解决这个问题 需要,openerp enterprise附带一个特殊的附加权限 致OpenERP Enterprise的每个订户,但仅限于 私人使用。我们认为这是贪婪者对工作的愚蠢剥削 公司。
示例用法
importunittestfromitsbroken.transactionimportTransactionfromitsbroken.testingimportDB_NAME,POOL,USER,CONTEXT, \ install_module,drop_databaseclassTestItsBroken(unittest.TestCase):""" Test the itsbroken library by connecting to an instance of OpenERP. By defualt OpenERP has the partner module and other core modules installed, so most of the test uses those modules. """defsetUp(self):install_module('product')deftest_0010_create(self):""" Test by creating a new product """withTransaction().start(DB_NAME,USER,CONTEXT)astxn:product_obj=POOL.get('product.product')values={'name':'Sharoon Thomas'}id=product_obj.create(txn.cursor,txn.user,values,txn.context)product=product_obj.browse(txn.cursor,txn.user,id)self.assertEqual(product.name,values['name'])if__name__=='__main__':unittest.main()
更多示例
这个模块本身的测试是一个很好的例子,说明了如何使用它的breaked for 测试。见tests/test_itsbroken.py。