Why don't my tests work on Odoo 10?

I created a simple application with the following structure:

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

In the test folder, I have:

  • tests / __ __ INIT ru :.
# -*- coding: utf-8 -*-
from . import tests_todo
  • 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')

I intentionally try to make tests fail by comparing boolean task.is_donewith a string 'foo', but I don't see anything in 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

What am I missing?

+4
source share
1 answer

Try renaming the test module tests / tests_todo.py to tests / test_todo.py . Also, be sure to update the import in tests / __ init __. Py upfrom . import test_todo

, Odoo , test_ , [].

+4

Source: https://habr.com/ru/post/1672573/


All Articles