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

  • Holger Nahrstaedt
  • Based on original work by Pierre Verkest and Camptocamp SA

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.1.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.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_oduit-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 fe4ed664e0d2857acf81fa51323b235beb9b6455acb74e190306f8eb4d137fea
MD5 28007c964fbad119a1daa3d9193d46ac
BLAKE2b-256 b0fb2817450fc36430e56963d94f48010bf996951c6d3e3bc59354c1e9590c4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_oduit-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b73b0cb4877f8f38c12dd3ca16e717fe0ef929e2e964a932190a62114ea74c4d
MD5 65114c98eab5934f441ee2158599bc51
BLAKE2b-256 cf03860fdb63267b56592621d9451a9a58d258288b91c9f1bf1a2bbdfacc3b64

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