Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 未在Odoo 12中运行(加载)单元测试_Python_Unit Testing_Odoo_Odoo 12 - Fatal编程技术网

Python 未在Odoo 12中运行(加载)单元测试

Python 未在Odoo 12中运行(加载)单元测试,python,unit-testing,odoo,odoo-12,Python,Unit Testing,Odoo,Odoo 12,我正试图在Odoo 12中为我的自定义模块代码编写单元测试,我遵循了Odoo 12的官方文档来编写单元测试和运行测试。但是,当我根据文档运行测试时,我看不到测试的结果。在服务器更新时,这些测试似乎没有运行,甚至没有加载 我按照Odoo 12文档说明运行并更新了服务器,并应用了此解决方案:。但我还是看不到测试结果 我的模块中的测试目录如下所示: ├── tests │ ├── __init__.py │ └── test_loan_request.py 我的init.py

我正试图在Odoo 12中为我的自定义模块代码编写单元测试,我遵循了Odoo 12的官方文档来编写单元测试和运行测试。但是,当我根据文档运行测试时,我看不到测试的结果。在服务器更新时,这些测试似乎没有运行,甚至没有加载

我按照Odoo 12文档说明运行并更新了服务器,并应用了此解决方案:。但我还是看不到测试结果

我的模块中的测试目录如下所示:

├── tests
    │   ├── __init__.py
    │   └── test_loan_request.py
我的init.py文件中有以下代码:

# -*- encoding: utf-8 -*-

from . import  test_loan_request
在test_loan_request.py中,我使用这些代码进行了一个简单的测试:

# -*- encoding: utf-8 -*-

from odoo.tests.common import TransactionCase, tagged


@tagged('loan')
class TestLoanRequest(TransactionCase):

    def test_loan_request_selection(self):
        print(':::::::::::::::::::::::::::::::::::::::::: In test method')
        loan_request = self.env['loan.request'].create({'selection': 'employee', 'amount': 5000 })
        self.assertEqual(loan_request.selection, 'employee')
        print('::::::::::::::::::::::::::::::::::::: After assertEqual')
我使用以下命令更新和运行模块中的单元测试:

./odoo-bin --addons-path=addons,../12.e,../netlinks-erp/addons -d netlinks_erp --xmlrpc-port=9000 --test-enable --test-tags hr_payroll_advance_request,loan
这是我通过运行上面的命令得到的结果:

2019-06-23 10:12:22,739 14712 INFO ? odoo: Odoo version 12.0 
2019-06-23 10:12:22,740 14712 INFO ? odoo: addons paths: ['/home/ibrahim/.local/share/Odoo/addons/12.0', '/home/ibrahim/workspace/odoo/12.0/addons', '/home/ibrahim/workspace/odoo/12.e', '/home/ibrahim/workspace/odoo/netlinks-erp/addons', '/home/ibrahim/workspace/odoo/12.0/odoo/addons'] 
2019-06-23 10:12:22,740 14712 INFO ? odoo: database: default@default:default 
2019-06-23 10:12:22,979 14712 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf 
2019-06-23 10:12:23,259 14712 INFO ? odoo.service.server: HTTP service (werkzeug) running on ubuntu:9000 
2019-06-23 10:12:23,284 14712 INFO netlinks_erp odoo.modules.loading: loading 1 modules... 
2019-06-23 10:12:23,322 14712 INFO netlinks_erp odoo.modules.loading: 1 modules loaded in 0.04s, 0 queries 
2019-06-23 10:12:23,494 14712 INFO netlinks_erp odoo.modules.loading: loading 135 modules... 
2019-06-23 10:12:24,186 14712 INFO netlinks_erp odoo.addons.sms.wizard.send_sms: The `phonenumbers` Python module is not available. Phone number validation will be skipped. Try `pip3 install phonenumbers` to install it. 
2019-06-23 10:12:24,501 14712 WARNING netlinks_erp odoo.models: The model generate.session.wizard has no _description 
2019-06-23 10:12:24,502 14712 WARNING netlinks_erp odoo.models: The model event.session has no _description 
2019-06-23 10:12:24,502 14712 WARNING netlinks_erp odoo.models: The model event.attendance has no _description 
2019-06-23 10:12:24,799 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.overtime has no _description 
2019-06-23 10:12:24,799 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.late has no _description 
2019-06-23 10:12:24,800 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.late.line has no _description 
2019-06-23 10:12:24,801 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.absence has no _description 
2019-06-23 10:12:24,801 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.absence.line has no _description 
2019-06-23 10:12:24,802 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.diff has no _description 
2019-06-23 10:12:24,803 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.diff.line has no _description 
2019-06-23 10:12:24,803 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.policies has no _description 
2019-06-23 10:12:24,804 14712 WARNING netlinks_erp odoo.models: The model hr.attendance.policies.line has no _description 
2019-06-23 10:12:24,807 14712 WARNING netlinks_erp odoo.models: The model hr.public.holidays has no _description 
2019-06-23 10:12:24,888 14712 WARNING netlinks_erp odoo.models: The model hr.academic has no _description 
2019-06-23 10:12:24,888 14712 WARNING netlinks_erp odoo.models: The model hr.experience has no _description 
2019-06-23 10:12:24,891 14712 WARNING netlinks_erp odoo.models: The model skill.skill has no _description 
2019-06-23 10:12:24,892 14712 WARNING netlinks_erp odoo.models: The model job.type has no _description 
2019-06-23 10:12:25,123 14712 WARNING netlinks_erp odoo.models: The model wiz.reject.ts has no _description 
2019-06-23 10:12:25,222 14712 WARNING netlinks_erp odoo.models: The model wiz.hr.emp.attendance has no _description 
2019-06-23 10:12:25,244 14712 INFO netlinks_erp odoo.modules.loading: 135 modules loaded in 1.75s, 0 queries 
2019-06-23 10:12:27,736 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,736 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,736 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,737 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,737 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,737 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,737 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,737 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,738 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,738 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,738 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,738 14712 INFO netlinks_erp odoo.fields: Field account.analytic.line.sheet_id depends on non-stored field account.analytic.line.sheet_id_computed 
2019-06-23 10:12:27,773 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,773 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,775 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,775 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,776 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,776 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,776 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,776 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,777 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,777 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,777 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,777 14712 INFO netlinks_erp odoo.fields: Field hr.attendance.sheet_id depends on non-stored field hr.attendance.sheet_id_computed 
2019-06-23 10:12:27,896 14712 INFO netlinks_erp odoo.modules.loading: Modules loaded. 
2019-06-23 10:12:27,915 14712 INFO netlinks_erp odoo.service.server: Starting post tests 
2019-06-23 10:12:28,366 14712 INFO netlinks_erp odoo.service.server: All post-tested in 0.45s, 0 queries 
2019-06-23 10:12:28,397 14712 INFO ? odoo.http: HTTP Configuring static files 
2019-06-23 10:12:28,404 14712 WARNING ? odoo.http: Logged into database 'test_db', but dbfilter rejects it; logging session out. 
2019-06-23 10:12:28,406 14712 INFO netlinks_erp odoo.addons.base.models.ir_http: Generating routing map 
2019-06-23 10:12:28,647 14712 INFO ? odoo.addons.bus.models.bus: Bus.loop listen imbus on db postgres 

我如何运行单元测试(我在模块的tests目录中有这些单元测试)并查看测试结果?

也许您缺少命令行中的-u your_module_to_测试

检查odoo配置中的db_filter参数。我认为这限制了加载您的db。@Burmespythis HilarAK,我从GitHub中的Odoo 12存储库中获得了一个克隆,并且我没有在Odoo conf文件中配置或更改任何内容。此外,我使用
--db\u filter=netlinks\u erp
运行服务器,但仍然没有加载或运行任何内容。如果我要更改odoo conf文件中的任何内容,我应该在那里更改什么?我在更新服务器时多次使用了上述命令,但仍然没有任何效果。您是否设法修复了它?我的评论是基于你没有在命令行中指定模块的-u部分,没有它,它将只运行带有数据库的服务器。实际上,我仍然无法运行我自己的测试,我尝试了许多解决方案,但我的测试没有运行。加入telegram中的开发人员,我们可以在那里亲自提供帮助,如果你在那里找到帮助,稍后会发布解决方案,只需在电报中找到odoo devs即可