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

How to use pytest when Odoo is running from docker container ? #39

Open
tarekmokhtarjr opened this issue Mar 23, 2021 · 5 comments
Open

Comments

@tarekmokhtarjr
Copy link

Hello guys,

first i would like to thank you for this awesome tool !
I'm running Odoo from docker container and what i did is the following :

  1. I got inside the container using this command docker exec -ti <my_odoo_container> bash
  2. Then i installed pytest-odoo inside the container pip3 install pytest-odoo
  3. I used this command to run the test pytest -s addons/<my_module>/tests/test_account_move.py --odoo-database=staging_3

But it gives me this error OSError: [Errno 98] Address already in use :
image

Did anyone encounter a similar issue ?

Thanks.

@yvaucher
Copy link
Member

Hello @tarek-caesar

Instead of using an existing container, you might prefer to create a new container just to run pytest if you need your server online at the same time.
Note that to run the tests you usually want to generate a new database in demo data mode.

If you use the docker-odoo-project image you can use the tools testdb-gen and testdb-update for this before launching pytest.

https://github.com/camptocamp/docker-odoo-project#pytests

@tarekmokhtarjr
Copy link
Author

@yvaucher

Thanks for your answer, i will check that.

@julia-suarez-deel
Copy link

Hello I figured this out, I wrote an article to explain better how to run odoo's tests with pycharm, generate coverage reports and get debugging working, I hope this is useful for you: https://medium.com/plusteam/how-to-run-odoo-tests-with-pycharm-51e4823bdc59.

I included an example repository with some commands to set up a testing database, etc.

@julia-suarez-deel
Copy link

@tarek-caesar btw, you can run the tests in the same container you regularly use, you just need to specify a different port, like this:

pytest -s addons/<my_module>/tests/test_account_move.py --odoo-database=staging_3 -p 8001

@The-macharia
Copy link

You can use the param --no-http to run another instance without stopping odoo or exposing new ports

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