Registry / testing / odoo-test-helper

odoo-test-helper

JSON →
library2.1.3pypypiunverified

Odoo Test Helper is a Python library providing a toolbox for writing Odoo tests, primarily by facilitating the loading of fake models. This is particularly useful for testing abstract Odoo modules where real record interaction is needed without actual database persistence. Maintained by the Odoo Community Association (OCA), the library is currently at version 2.1.3 and has an infrequent, as-needed release cadence.

pip install odoo-test-helper
INSTALL
IMPORT
SIG · ODOO-TEST-HELPER
O
odoo-test-helper
testingpythonv2.1.3
Install
1.5s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FakeModelLoader
✓ from odoo_test_helper import FakeModelLoader
✗ from odoo_test_helper import FakeModelLoader

This quickstart demonstrates how to set up and use a fake Odoo model within a test case. It shows the correct placement for importing fake models (after `backup_registry`) and how to clean up the registry afterwards.

from odoo.tests import SavepointCase from odoo_test_helper import FakeModelLoader # Define your fake models in a file like 'models.py' in the same directory # Example models.py content: # from odoo import models, fields # class ResPartner(models.Model): # _name = 'res.partner' # _description = 'Fake Partner' # name = fields.Char() class TestFakeModel(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() # IMPORTANT: Import your fake models AFTER backup_registry() from .models import ResPartner # Assuming 'models.py' contains ResPartner cls.loader.update_registry((ResPartner,)) # Now you can use your fake model cls.test_partner = cls.env['res.partner'].create({'name': 'Test Partner'}) @classmethod def tearDownClass(cls): cls.loader.restore_registry() super().tearDownClass() def test_fake_partner_creation(self): self.assertEqual(self.test_partner.name, 'Test Partner')
Debug
Known issues
breakingThis library is explicitly not needed for Odoo 19+ versions. Odoo 19 and newer provide native functionality to achieve the same testing goals, rendering `odoo-test-helper` obsolete for these versions.
fix
For Odoo 19+, migrate to native Odoo testing mechanisms. Refer to Odoo's official documentation and OCA migration guides for equivalent native patterns.
affects: Odoo 19.0+
gotchaThe PyPI development status for `odoo-test-helper` is classified as '2 - Pre-Alpha'. This indicates that the project is still under active development, may have an unstable API, and could introduce breaking changes or significant modifications without a full deprecation cycle.
fix
Exercise caution when using in production-critical test suites. Monitor the GitHub repository for updates and be prepared for potential API changes. Consider pinning to a specific version.
affects: All versions
gotchaIncorrect import order of fake Odoo models (e.g., `ResPartner` in the example) can lead to Odoo registry corruption or unexpected behavior. Fake models must be imported *after* `cls.loader.backup_registry()` has been called in `setUpClass`.
fix
Always ensure that `from .models import YourFakeModel` statements for test-specific models are placed after `cls.loader.backup_registry()` to correctly manage the Odoo registry context.
affects: All versions
Upgrade
Version history
2.1.3latest on PyPI · released Feb 20, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.8 or higher.
Agent activity
21 hits · last 30 days
node
20
Resources
odoo-test-helper — pip install odoo-test-helper · libregistry