Skip to main content

py.test plugin to run Odoo tests

Project description

pytest plugin to run Odoo tests

This lib allows to run the tests built in Odoo addons which are using Python’s unittest, but with the comfort of the pytest CLI. Also allowing to run tests without updating given module.

Odoo’s –test-enable machinery and pytest-odoo do not cover exactly the same scope. The Odoo’s test runner runs the tests during the upgrades of the addons, that’s why they need the “at install” and “post install” markers.

Running tests during upgrades of addons is waaay too slow to work efficiently in a TDD mode, that’s where pytest-odoo shines. Consider that all the tests are running post-install with pytest-odoo, as you must run the upgrade of the addon before (but only when needed vs each run).

At the end of the day, its beneficial to run the Odoo tests with –test-enable because, as in very rare conditions, a test can pass with pytest-odoo but not with the “at install” tests run during the upgrade (or the oposite). Pytest-odoo can be considered a development tool, but not the tool that should replace entirely –test-enable in a CI.

See also the official Odoo documentation on writing tests.

Usage

install via:

pip install pytest-odoo

usage:

pytest -s --odoo-database=test --odoo-log-level=debug_sql [--odoo-http]

The custom options are:

  • --odoo-database: name of the database to test.

  • --odoo-log-level: log level as expected by odoo. As time of writing: info, debug_rpc, warn, test, critical, debug_sql, error, debug, debug_rpc_answer. The default is critical to have a clean output.

  • --odoo-config: path of the odoo.cfg file to use.

  • --odoo-http: Allow to launch the Odoo http instance

Alternatively, you can use environment variables, like the Odoo Docker image:

  • HOST: hostname of the database server

  • PORT: port of the database server

  • USER: username to access the database

  • PASSWORD: password to access the database

These only work in addition to --odoo-database.

You can use the ODOO_RC environment variable using an odoo configuration file, containing at least the database option with the name of the database to test:

export ODOO_RC=/path/to/odoo/config.cfg
pytest ...

Known issues

Currently not compatible with pytest >= 8.0.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_odoo-1.0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

pytest_odoo-1.0.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_odoo-1.0.1.tar.gz.

File metadata

  • Download URL: pytest_odoo-1.0.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pytest_odoo-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8e40fef6cdab27119a69bbfbddbf4470b4abd078dcef4398d4972b23f91e7ac6
MD5 8f06bdb1bcf7c9578202b7cd310f3818
BLAKE2b-256 672fcac3f2d6ed2e5055464080f08f1684a15e92b24679a761e5ecf0e95d54bd

See more details on using hashes here.

File details

Details for the file pytest_odoo-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_odoo-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pytest_odoo-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d709b9f961fcd5c1ee8c4b69e05b0f6b7a7700375f7f06f53f8fd9cf4578158
MD5 6307aeb48efad5afb61fb1a45f523e8f
BLAKE2b-256 bc01bc782f9a2b48993717b0f1034f90bbda211dc14e506fc7a7a02d2ce48f86

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page