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

Requirements

  • Python >= 3.9
  • pytest >= 8
  • oduit
  • Odoo (any supported version)

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-http: Launch an Odoo HTTP server during tests
  • --odoo-dev: Development mode options

Configuration

The plugin automatically detects and uses .oduit.toml configuration files when available. This provides seamless integration with oduit-core 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.2.0.tar.gz (24.0 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.2.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_oduit-0.2.0.tar.gz
  • Upload date:
  • Size: 24.0 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.2.0.tar.gz
Algorithm Hash digest
SHA256 fa1cb0ef8aa62f22e0ab528758f4856faf9c123e8e1f40575b01bd4defa5f303
MD5 0bbd748786f71d61eb66f9e4bcd671df
BLAKE2b-256 f3cfc0d2d252659fd2ae5d902e96a31fd79279ef994d7db281ab5d81802db67a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_oduit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc37b60ab1950c6c9f1eefd30f1f88e479483e6f9a661d5446a393eb69b5a32b
MD5 8d5269c41de6865dea3d072593af79fb
BLAKE2b-256 5a88275c0425b24bfa41bb213dabf63885c88ccc708848c878377b0d2a8d3681

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