2017-03-17 116 views
4

我創建了一個簡單的待辦事項應用結構如下:爲什麼我的測試不能在Odoo 10上運行?

todo_app 
    ├── __init__.py 
    ├── __manifest__.py 
    ├── tests 
    │   ├── __init__.py 
    │   └── tests_todo.py 
    └── todo_model.py 

在測試文件夾中我有:

  • 測試/ __ init__.py
# -*- coding: utf-8 -*- 
from . import tests_todo 
  • 測試/ tests_todo.py
# -*- coding: utf-8 -*- 
from odoo.tests.common import TransactionCase 


class TestTodo(TransactionCase): 

    def test_create(self): 
     """ 
     Create a simple Todo 
     """ 
     Todo = self.env['todo.task'] 
     task = Todo.create({'name': 'Test Task'}) 
     self.assertEqual(task.is_done, 'foo') 

我刻意用布爾task.is_done以字符串'foo'比較讓測試失敗,但我沒有看到日誌東西:

$ ./odoo/odoo-bin -d todo -u todo_app --test-enable 
2017-03-17 14:25:28,617 6873 INFO ? odoo: Odoo version 10.0 
2017-03-17 14:25:28,618 6873 INFO ? odoo: Using configuration file at /home/odoo/.odoorc 
2017-03-17 14:25:28,618 6873 INFO ? odoo: addons paths: ['/home/odoo/.local/share/Odoo/addons/10.0', u'/home/odoo/odoo-dev/custom-addons', u'/home/odoo/odoo-dev/odoo/addons', '/home/odoo/odoo-dev/odoo/odoo/addons'] 
2017-03-17 14:25:28,619 6873 INFO ? odoo: database: [email protected]:default 
2017-03-17 14:25:28,832 6873 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069 
2017-03-17 14:25:29,558 6873 INFO todo odoo.modules.loading: loading 1 modules... 
2017-03-17 14:25:29,996 6873 INFO todo odoo.modules.loading: 1 modules loaded in 0.44s, 0 queries 
2017-03-17 14:25:41,792 6873 INFO todo odoo.modules.loading: loading 13 modules... 
2017-03-17 14:25:42,001 6873 INFO todo odoo.modules.registry: module todo_app: creating or updating database tables 
2017-03-17 14:25:42,889 6873 INFO todo odoo.modules.loading: 13 modules loaded in 1.10s, 0 queries 
2017-03-17 14:25:43,059 6873 WARNING todo odoo.modules.loading: The model todo.task has no access rules, consider adding one. E.g. access_todo_task,access_todo_task,model_todo_task,,1,0,0,0 
2017-03-17 14:25:43,625 6873 INFO todo odoo.modules.loading: Modules loaded. 
2017-03-17 14:25:43,630 6873 INFO todo odoo.modules.loading: All post-tested in 0.00s, 0 queries 

我錯過了什麼?

回答

4

嘗試重命名測試模塊測試/ tests_todo.py測試/ test_todo.py。另外,不要忘記在測試/ __更新進口init__.pyfrom . import test_todo

這是因爲Odoo預計測試模塊的名字開始與test_當它搜索屬於模塊[reference]測試。

+0

我覺得很愚蠢。謝謝! –

相關問題