Search code examples
unit-testingodooodoo-14odoo-15odoo-16

Odoo Unit Test is not running


I am running the following command inside docker container of odoo image 16 and it doesn't run the unit-test:

odoo -i custom_fields_mapping -d odootest8 -p 8001 --db_user=odoo --db_password=11111111111 --db_host=localhost --log-level=test --test-file=/mnt/extra-addons/custom_fields_mapping/tests/test_custom_fields_mapping.py --stop-after-init

and the log is:

2023-03-21 13:52:32,550 414 INFO odootest8 odoo.modules.loading: Modules loaded.
2023-03-21 13:52:32,556 414 INFO odootest8 odoo.modules.registry: Registry loaded in 1.824s
2023-03-21 13:52:32,558 414 INFO odootest8 odoo.service.server: loading test file /mnt/extra-addons/custom_fields_mapping/tests/test_custom_fields_mapping.py
2023-03-21 13:52:32,581 414 INFO odootest8 odoo.service.server: Initiating shutdown
2023-03-21 13:52:32,581 414 INFO odootest8 odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.
2023-03-21 13:52:32,735 414 DEBUG odootest8 odoo.service.server: on_close call <bound method Event.set of <threading.Event object at 0x7fba555e6fd0>>
2023-03-21 13:52:32,735 414 DEBUG odootest8 odoo.service.server: on_close call <bound method Websocket._kick_all of <class 'odoo.addons.bus.websocket.Websocket'>>
2023-03-21 13:52:32,735 414 DEBUG odootest8 odoo.service.server: current thread: <_MainThread(MainThread, started 140438395283264)>
2023-03-21 13:52:32,735 414 DEBUG odootest8 odoo.service.server: process <_MainThread(MainThread, started 140438395283264)> (False)
2023-03-21 13:52:32,736 414 INFO odootest8 odoo.sql_db: ConnectionPool(used=0/count=0/max=64): Closed 1 connections
2023-03-21 13:52:32,736 414 DEBUG odootest8 odoo.service.server: --

EDIT: I have the same problem in version 14 and 15


Solution

  • My problem was at the tests folder I missed to add the file __init__.py, then the test was run normally

    The command to run the test was:

    • version 14:
    odoo -i custom_fields_mapping -d odootest2 -p 8001 --db_user=odoo --db_password=secret-pw --db_host=172.19.0.2 --log-level=test --test-enable --test-file=/mnt/extra-addons/custom_fields_mapping/tests/test_custom_fields_mapping.py --stop-after-init
    
    • version 15 and 16:
    odoo -i custom_fields_mapping -d odootest2 -p 8001 --db_user=odoo --db_password=secret-pw --db_host=172.20.0.2 --log-level=test --test-file=/mnt/extra-addons/custom_fields_mapping/tests/test_custom_fields_mapping.py --stop-after-init