当我开始学习如何测试一个程序时,我学到的就是用与测试程序相同的语言使用一个库或包。例如,
- if a tested program is written in Python, its testing program is also written in Python and uses `UnitTest` class in the python standard library
- if a tested program is written in C++, its testing program is also written in C++ and uses some test
看起来,每当我在测试用例中使用transaction.set_autocommit(False)时,都会得到以下堆栈跟踪:
transaction.set_autocommit(False)
File "/Users/btoueg/src/python/python3.3.3_django1.6.1/lib/python3.3/site-packages/django/db/transaction.py", line 133, in set_autocommit
return get_connection(using).set_autocommit(auto
因此,我使用boost::python (C++)创建了一个共享库。对于内部的C++函数,我有单元测试,检查它们是否正常工作。现在,我想使用单元测试来查看我是否正确地实现了python接口。为此,我考虑使用python包unittest。
现在,我的文件夹设置大致是:
project
|
-- C++ source (library and boost::python stuff)
|
-- build (here the shared library is located)
|
-- Test (here I have the python classes th
当我尝试在RichDocuments上运行单元测试时,我得到一个错误:
[jd@jd:~/sandbox/trunk/eggs/Products.RichDocument-3.0.2-py2.4.egg/Products/RichDocument/tests]$ python ./testSetup.py
Traceback (most recent call last):
File "./testSetup.py", line 1, in ?
from Products.RichDocument.tests import base
ImportError: No module
我正在将代码库从Python2升级到Python3。
Python3代码中的测试用例失败,因为set()函数生成的顺序与Python2不同。
例如:
# Here in Python 2.7 the PYTHONHASHSEED is disabled.
list = {"it","is","rishabh","Mishra"}
# Below, in Python 3
list = {"rishabh","it","is","mishra"}
我希望顺序与Pyth