为什么我的测试无法在Odoo 10上运行? [英] Why are my tests not running on Odoo 10?

查看:234
本文介绍了为什么我的测试无法在Odoo 10上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有以下结构的简单待办事项应用程序:

I created a simple to-do application with the following structure:

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/tests_todo.py :
    • tests/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'进行比较来使测试失败,但是我在日志中看不到任何内容:

      I am deliberately trying to make the tests fail by comparing the boolean task.is_done with the string 'foo' but I don't see anything on the logs:

      $ ./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: default@default: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
      

      我想念什么?

      推荐答案

      尝试将测试模块 tests/tests_todo.py 重命名为 tests/test_todo.py .另外,不要忘记将 tests/__ init __.py 中的导入更新为from . import test_todo

      Try renaming the test module tests/tests_todo.py to tests/test_todo.py. Also, don't forget to update the import in tests/__init__.py to from . import test_todo

      这是因为Odoo在搜索属于某个模块的测试时希望测试模块名称以test_开头[

      This is because Odoo expects the test module names to start with test_ when it searches for tests belonging to a module [reference].

      这篇关于为什么我的测试无法在Odoo 10上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆