Skip to main content

py.test plugin to run Odoo tests

Project description

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.1.0.tar.gz (23.9 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.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_oduit-0.1.0.tar.gz
  • Upload date:
  • Size: 23.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 99378474f11e87e0f8fc2bf4de56b3f4d78b7407a5668b5500d88ea9c0a279b3
MD5 4752a2e299f514547fe1634bad4980ba
BLAKE2b-256 daf23e7ead08f2ef46c12042cac40192f2aac5f5a4acee31647a0e77cb19f28f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_oduit-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f7437ea736c9c7dd41f08c5a7dd0d11dd03ec18dc48545eff3565bfc033e4cd
MD5 767fd40df910a7150bda60d0f8026c9d
BLAKE2b-256 ce0e2a960732cced57e0846e958f464f0d963f760609eb2733dcf6e1775df847

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