Skip to main content

py.test plugin to run Odoo tests

Project description

codecov

pytest-oduit

A pytest plugin for running Odoo tests with enhanced functionality and integration with oduit-core.

Features

  • Automatic Odoo configuration: Integrates with .oduit.toml configuration files using oduit-core
  • Module path resolution: Automatically resolves Odoo addon module paths for proper test discovery
  • Test retry management: Disables Odoo's built-in test retry mechanism to work seamlessly with pytest
  • Distributed testing support: Works with pytest-xdist for parallel test execution
  • HTTP server support: Optional Odoo HTTP server launch for integration tests

Installation

pip install pytest-oduit

Note: pytest-odoo must not be installed.

Requirements

  • Python >= 3.9
  • pytest >= 8
  • oduit
  • Odoo >= 15.0

Usage

Basic Usage

Simply run pytest in your Odoo addon directory:

pytest

Other pytest plugins

This plugin works also together pytest-subtests and pytest-xdist.

Command Line Options

  • --odoo-log-level: Set the log level for Odoo processes during tests (default: 'critical')
  • --odoo-install: Set a module to install during tests
  • --oduit-env: Set the oduit config file, when not specified a local .oduit.toml configuration is needed.oduit.toml` configuration is needed.

Configuration

The plugin automatically detects and uses .oduit.toml configuration files when available. This provides seamless integration with oduit for database configuration, addon paths, and other Odoo settings.

Example .oduit.toml:

[odoo]
db_name = "test_db"
addons_path = ["./addons", "./custom_addons"]

Module Path Resolution

The plugin automatically resolves Odoo addon module paths, ensuring that:

  • Test modules in addon_name/tests/ are properly recognized as odoo.addons.addon_name.tests.test_module
  • Only installable addons (with installable: True in __manifest__.py) are collected for testing
  • Namespace packages are handled correctly

Distributed Testing

Works seamlessly with pytest-xdist for parallel test execution:

pytest -n auto  # Run tests in parallel using all available CPUs

The plugin automatically creates isolated database copies for each worker to prevent conflicts.

Development

Running Tests

cd pytest-oduit
pytest

Test Structure

The plugin includes comprehensive tests that use mock Odoo modules to verify functionality without requiring a full Odoo installation.

License

AGPLv3 - see LICENSE file for details.

Authors

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

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_oduit-0.3.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_oduit-0.3.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_oduit-0.3.0.tar.gz.

File metadata

  • Download URL: pytest_oduit-0.3.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_oduit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1ae05e1686504c2d64a98e50a8c6a6141076b2a6627e405aaddcd8185be996e3
MD5 fd3134cb7850fb6f00ee4cbde2b413c2
BLAKE2b-256 ad1bca101f700ddc285d3bf8cf4a626bf97bae002742b40aa62f91e166f4632d

See more details on using hashes here.

File details

Details for the file pytest_oduit-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_oduit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_oduit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ac9929b1081be5cf2bb1295eb021e4ad5c5bfa057e47ad30d1358ecc7fd45a1
MD5 2cb84de7b80ed71f67ff5c30b252e95c
BLAKE2b-256 4fcee1d0dceb1a3dac891534a57af1a9db1b2e47546b5178da4f6813282d3277

See more details on using hashes here.

Supported by

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