{"id":9150,"library":"odoo-test-helper","title":"Odoo Test Helper","description":"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.","status":"active","version":"2.1.3","language":"python","source_language":"en","source_url":"https://github.com/OCA/odoo-test-helper","tags":["odoo","testing","test-helper","fake-models","orm","oca"],"install":[{"cmd":"pip install odoo-test-helper","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.8 or higher.","package":"python","optional":false}],"imports":[{"wrong":"from odoo_test_helper import FakeModelLoader","symbol":"FakeModelLoader","correct":"from odoo_test_helper import FakeModelLoader"}],"quickstart":{"code":"from odoo.tests import SavepointCase\nfrom odoo_test_helper import FakeModelLoader\n\n# Define your fake models in a file like 'models.py' in the same directory\n# Example models.py content:\n# from odoo import models, fields\n# class ResPartner(models.Model):\n#     _name = 'res.partner'\n#     _description = 'Fake Partner'\n#     name = fields.Char()\n\nclass TestFakeModel(SavepointCase):\n\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        cls.loader = FakeModelLoader(cls.env, cls.__module__)\n        cls.loader.backup_registry()\n\n        # IMPORTANT: Import your fake models AFTER backup_registry()\n        from .models import ResPartner # Assuming 'models.py' contains ResPartner\n\n        cls.loader.update_registry((ResPartner,))\n\n        # Now you can use your fake model\n        cls.test_partner = cls.env['res.partner'].create({'name': 'Test Partner'})\n\n    @classmethod\n    def tearDownClass(cls):\n        cls.loader.restore_registry()\n        super().tearDownClass()\n\n    def test_fake_partner_creation(self):\n        self.assertEqual(self.test_partner.name, 'Test Partner')","lang":"python","description":"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."},"warnings":[{"fix":"For Odoo 19+, migrate to native Odoo testing mechanisms. Refer to Odoo's official documentation and OCA migration guides for equivalent native patterns.","message":"This 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.","severity":"breaking","affected_versions":"Odoo 19.0+"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Incorrect 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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2.1.3':58 'abstract':32 'actual':42 'as-need':63 'associ':50 'cadenc':67 'communiti':49 'current':55 'databas':43 'facilit':20 'fake':24,74 'fake-model':73 'helper':3,6,72 'infrequ':62 'interact':38 'librari':10,53 'load':22 'maintain':45 'model':25,75 'modul':34 'need':40,65 'oca':51,77 'odoo':1,4,16,33,48,68 'orm':76 'particular':28 'persist':44 'primarili':18 'provid':11 'python':9 'real':36 'record':37 'releas':66 'test':2,5,17,31,69,71 'test-help':70 'toolbox':13 'use':29 'version':57 'without':41 'write':15","created_at":"2026-04-16T18:48:43.783759+00:00","updated_at":"2026-04-16T18:48:43.783759+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpllcjkcxb/venv/lib/python3.12/site-packages/odoo_test_helper/__init__.py\", line 1, in <module>\n    from .fake_model_loader import FakeModelLoader  # noqa\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.1.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/oca/odoo-test-helper","docs":"https://github.com/oca/odoo-test-helper","changelog":null,"pypi":"https://pypi.org/project/odoo-test-helper/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}