我可以按照here所述运行openerpv7附加组件的单元测试。在
在PyCharm中,我在运行/调试配置中添加了一个Python配置,如下所示:
脚本:
/home/juliocesar/work/projects/my_project/openerp-server
脚本参数:
^{pr2}$它成功运行,但以文本日志格式显示标准输出,如下所示:
2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: module my_addon: executing 1 `fast_suite` and/or `checks` sub-modules
2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: test_change_old_received_to_contingency (openerp.addons.my_addon.tests.test_my_addon.TestMyItems)
2015-04-24 13:47:55,101 12340 TEST my_project openerp.modules.module: ` Test patch to change old received status to contingency.
2015-04-24 13:47:55,110 12340 TEST my_project openerp.modules.module: Ran 1 tests in 0.006s
2015-04-24 13:47:55,110 12340 TEST my_project openerp.modules.module: OK
其中它显示了运行我在项目my_project
,在/home/juliocesar/work/projects/my_project/openerp/addons/my_addon/tests/test_my_addon.py
中的附加组件my_addon
中创建的以下测试的结果:
from openerp.tests.common import TransactionCase
import unittest2
class TestMyItems(TransactionCase):
def test_change_old_received_to_contingency(self):
"""Test patch to change old received status to contingency."""
self.assertTrue(True)
if __name__ == '__main__':
unittest2.main()
我想要的是使用Python tests->;Unittest配置来显示带有红/绿图标的测试输出和测试结果的PyCharm界面。在
Unittest配置需要测试所在的脚本文件,如果我指定该文件,PyCharm会查找文件中的所有测试,但会出错,因为没有配置数据库(以及其他参数,如openerp-server
脚本和上面指定的用于运行OpenERP测试的rest参数):
这是运行此配置的结果:
/usr/bin/python2.7 /home/juliocesar/apps/pycharm/helpers/pycharm/utrunner.py /home/juliocesar/work/projects/my_project/openerp/addons/my_addon/tests/ false
Testing started at 09:38 AM ...
No handlers could be found for logger "openerp.sql_db"
Process finished with exit code 0
Error
Traceback (most recent call last):
File "/home/juliocesar/work/projects/my_project/openerp/tests/common.py", line 94, in setUp
TransactionCase.cr = self.cursor()
File "/home/juliocesar/work/projects/my_project/openerp/tests/common.py", line 55, in cursor
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
File "/home/juliocesar/work/projects/my_project/openerp/modules/registry.py", line 193, in get
update_module)
File "/home/juliocesar/work/projects/my_project/openerp/modules/registry.py", line 209, in new
registry = Registry(db_name)
File "/home/juliocesar/work/projects/my_project/openerp/modules/registry.py", line 76, in __init__
cr = self.db.cursor()
File "/home/juliocesar/work/projects/my_project/openerp/sql_db.py", line 484, in cursor
return Cursor(self._pool, self.dbname, serialized=serialized)
File "/home/juliocesar/work/projects/my_project/openerp/sql_db.py", line 182, in __init__
self._cnx = pool.borrow(dsn(dbname))
File "/home/juliocesar/work/projects/my_project/openerp/sql_db.py", line 377, in _locked
return fun(self, *args, **kwargs)
File "/home/juliocesar/work/projects/my_project/openerp/sql_db.py", line 440, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: database "False" does not exist
那么,如何使用PyCharm测试配置来指定运行openerpv7 unittest所需的参数呢?在
我使用了PyCharm 4.0.6构建版本PY-139.1659,但它在PyCharm 5中也不起作用。在
在“运行/调试”窗口中,是否将当前工作目录字段的值设置为
/home/juliocesar/work/projects/my_project
?这将有助于PyCharm寻找相对路径以及进口。在您也可以尝试在参数列表中给出加载项的完整路径。在
您可以使用
cmd
在windows中使用cmd into进行调试奥多.exe文件夹C:\Program Files (x86)\Odoo 8.0-20150719\server
并执行此命令或者在Linux下用terminal into进入终端奥多比文件(/usr/bin/)并执行此命令
^{pr2}$用ctrl+z或ctrl+c来取消激活日志。在
您将找到一个文件(openerp-服务器日志)在/var/log/odoo/
相关问题 更多 >
编程相关推荐