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 the OPENERP_SERVER environment variable using an odoo configuration file, containing at least the database option with the name of the database to test:

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

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.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

pytest_odoo-1.0.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest-odoo-1.0.0.tar.gz.

File metadata

  • Download URL: pytest-odoo-1.0.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pytest-odoo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e49c47067c2195e2f092c242083a8cb5d224dad8a21e9a37321d00db52da73ad
MD5 31e40e033d06775f47c775bdfd10c694
BLAKE2b-256 f46a7871252a493780c480031d410f805bc0438921a9a9a19f527247aca8bba0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_odoo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pytest_odoo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d10a8aeafafa9353a3d15d45e31d1d8b7a42173322f00a773cb3bde55783f12d
MD5 fb1efb438a02a68b3c36c761d65732c3
BLAKE2b-256 d16c5ccd8e81fbc4c07fdbbbed643a129209242a5423f2c206508be77eb3fb35

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