Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'odoo.addons.tiny_apps' #45

Open
odoo-sh opened this issue Feb 28, 2022 · 8 comments
Open

ModuleNotFoundError: No module named 'odoo.addons.tiny_apps' #45

odoo-sh opened this issue Feb 28, 2022 · 8 comments

Comments

@odoo-sh
Copy link

odoo-sh commented Feb 28, 2022

Hello,

Trying to run a test per module using cmd but getting import errors. any idea?
pytest --odoo-config=/odoo/conf/odoo.cfg --odoo-database=testdb --odoo-log-level=debug --junitxml=junit-report.xml -s /odoo/src/tiny_apps/tiny_apps/purchase_batch_order

odoo@review-develop-3zknud:~$ pytest --odoo-config=/odoo/conf/odoo.cfg --odoo-database=lasgdb --odoo-log-level=debug --junitxml=junit-report.xml -s /odoo/src/tiny_apps/tiny_apps/purchase_batch_order
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: "odoo.http.rpc.request:INFO"
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: "odoo.http.rpc.response:INFO"
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: ":INFO"
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: "odoo:DEBUG"
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: "odoo.sql_db:INFO"
2022-02-28 15:19:29,231 450 DEBUG ? odoo.netsvc: logger level set: "longpolling:WARNING"
2022-02-28 15:19:29,434 450 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2022-02-28 15:19:29,438 450 INFO ? odoo.addons.base.models.ir_actions_report: Wkhtmltopdf seems to be broken.
2022-02-28 15:19:29,575 450 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:9069
2022-02-28 15:19:29,576 450 INFO ? odoo.service.server: Stopping gracefully
================================================================================ test session starts =================================================================================
platform linux -- Python 3.7.12, pytest-7.0.1, pluggy-0.13.1
rootdir: /odoo
plugins: cov-3.0.0, odoo-0.7.1
collected 0 items / 1 error

======================================================================================= ERRORS =======================================================================================
______________________________________________ ERROR collecting src/tiny_apps/tiny_apps/purchase_batch_order/tests/test_batch_order.py _______________________________________________
.local/lib/python3.7/site-packages/pytest_odoo.py:140: in _importtestmodule
import(modname)
E ModuleNotFoundError: No module named 'odoo.addons.tiny_apps'
------------------------------------------------------------------ generated xml file: /home/odoo/junit-report.xml -------------------------------------------------------------------
============================================================================== short test summary info ===============================================================================
ERROR ../../odoo/src/tiny_apps/tiny_apps/purchase_batch_order/tests/test_batch_order.py - ModuleNotFoundError: No module named 'odoo.addons.tiny_apps'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================== 1 error in 0.20s ==================================================================================

@Jerther
Copy link

Jerther commented Feb 28, 2022

Try adding the -v argument. I had a similar problem a month ago and this fixed it, for some reason...

@simahawk
Copy link
Member

simahawk commented Mar 1, 2022

Are you sure the module is installed? Can you run tests w/ std odoo command? odoo -d XXX -i $mod_name --stop-after-init --test-enable?

@odoo-sh
Copy link
Author

odoo-sh commented Mar 1, 2022

Hello,

yes, the module is installed as you can see in runtest.log

We are executing pytest at first followed by odoo --test-enable.
runtests.log

UPDATE: the run test with standard odoo command succeed.

@simahawk
Copy link
Member

simahawk commented Mar 1, 2022

Are you sure tests are running w/ odoo? Do you import your test file in tests/__init__.py?
Bear in mind that if this is not the case, pytest will find it, odoo won't.
Very likely you have a problem on an import.

@odoo-sh
Copy link
Author

odoo-sh commented Mar 1, 2022

yes. we did import our testfile in tests/__init__.py
odoo -d xxx -i $mod_name --stop-after-init --test-enable succeed.

As a workaround we changed the following and it worked.

Commented line 122:  pkgroot = pypkgpath.dirpath()
Changed line 124:   
names = self.fspath.new(ext="").relto(pkgroot).split(sep)
To
names = self.fspath.new(ext="").relto(pypkgpath).split(sep)

@simahawk
Copy link
Member

simahawk commented Mar 1, 2022

ok, but the fact that I see no module named 'odoo.addons.tiny_apps' makes me think you have a problem.
AFAIS tiny_apps is a folder and not and addon.
However is a bit hard to judge w/out knowing your setup.

@odoo-sh
Copy link
Author

odoo-sh commented Mar 1, 2022

yes tiny_apps is a folder. we have addons_path=... , /odoo/src/tiny_apps/tiny_apps, .....
tiny_apps folder has many modules with test.
We want to run pytest for selective modules.

@idadzie
Copy link

idadzie commented Oct 31, 2022

@odoo-sh export the OPENERP_SERVER environment variable

In terminal

export OPENERP_SERVER=/path/to/odoo.cfg

or in your bashrc or zshrc file append

export OPENERP_SERVER=/path/to/odoo.cfg

and reload the shell with exec $SHELL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants