pytest-odoo


Namepytest-odoo JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/camptocamp/pytest-odoo
Summarypy.test plugin to run Odoo tests
upload_time2024-10-06 23:07:08
maintainerNone
docs_urlNone
authorGuewen Baconnier
requires_python>=3.8
licenseAGPLv3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            pytest-odoo
===========

pytest plugin to run Odoo tests

This lib allows to run the tests built in Odoo addons which are using Python's `unittest <https://docs.python.org/3/library/unittest.html>`_, but with the comfort of the `pytest <https://docs.pytest.org/>`_ CLI. 
Also allowing to run tests without updating given module.

Odoo's `--test-enable` machinery and pytest-odoo do not cover exactly the same scope. The Odoo's test runner runs the tests during
the upgrades of the addons, that's why they need the "at install" and "post install" markers.

Running tests during upgrades of addons is waaay too slow to work efficiently in a TDD mode, that's where pytest-odoo shines.
Consider that all the tests are running `post-install` with pytest-odoo, as you must run the upgrade of the addon before (but only when needed vs each run).

At the end of the day, its beneficial to run the Odoo tests with `--test-enable` because, as in very rare conditions,
a test can pass with pytest-odoo but not with the "at install" tests run during the upgrade (or the oposite).
Pytest-odoo can be considered a development tool, but not the tool that should replace entirely `--test-enable` in a CI.

See also the `official Odoo documentation <https://www.odoo.com/documentation/15.0/developer/reference/backend/testing.html#testing-python-code>`_ on writing tests.

Usage
-----

install via::

    pip install pytest-odoo

usage::

   pytest -s --odoo-database=test --odoo-log-level=debug_sql [--odoo-http]

The custom options are:

* ``--odoo-database``: name of the database to test.
* ``--odoo-log-level``: log level as expected by odoo. As time of writing: info, debug_rpc, warn, test, critical, debug_sql, error, debug, debug_rpc_answer. The default is critical to have a clean output.
* ``--odoo-config``: path of the odoo.cfg file to use.
* ``--odoo-http``: Allow to launch the Odoo http instance


Alternatively, you can use environment variables, like the Odoo Docker image:

* ``HOST``: hostname of the database server
* ``PORT``: port of the database server
* ``USER``: username to access the database
* ``PASSWORD``: password to access the database

These only work in addition to ``--odoo-database``.

You can use the ``ODOO_RC`` environment variable using an odoo configuration file, containing at least the ``database`` option with the name of the database to test::

   export ODOO_RC=/path/to/odoo/config.cfg
   pytest ...


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/camptocamp/pytest-odoo",
    "name": "pytest-odoo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Guewen Baconnier",
    "author_email": "guewen.baconnier@camptocamp.com",
    "download_url": "https://files.pythonhosted.org/packages/f9/bb/397f42423f99370bac1830f7fdc569f59b9a5ec3ff798ef3bf3555d9dbfc/pytest_odoo-2.0.0.tar.gz",
    "platform": "any",
    "description": "pytest-odoo\n===========\n\npytest plugin to run Odoo tests\n\nThis lib allows to run the tests built in Odoo addons which are using Python's `unittest <https://docs.python.org/3/library/unittest.html>`_, but with the comfort of the `pytest <https://docs.pytest.org/>`_ CLI. \nAlso allowing to run tests without updating given module.\n\nOdoo's `--test-enable` machinery and pytest-odoo do not cover exactly the same scope. The Odoo's test runner runs the tests during\nthe upgrades of the addons, that's why they need the \"at install\" and \"post install\" markers.\n\nRunning tests during upgrades of addons is waaay too slow to work efficiently in a TDD mode, that's where pytest-odoo shines.\nConsider that all the tests are running `post-install` with pytest-odoo, as you must run the upgrade of the addon before (but only when needed vs each run).\n\nAt the end of the day, its beneficial to run the Odoo tests with `--test-enable` because, as in very rare conditions,\na test can pass with pytest-odoo but not with the \"at install\" tests run during the upgrade (or the oposite).\nPytest-odoo can be considered a development tool, but not the tool that should replace entirely `--test-enable` in a CI.\n\nSee also the `official Odoo documentation <https://www.odoo.com/documentation/15.0/developer/reference/backend/testing.html#testing-python-code>`_ on writing tests.\n\nUsage\n-----\n\ninstall via::\n\n    pip install pytest-odoo\n\nusage::\n\n   pytest -s --odoo-database=test --odoo-log-level=debug_sql [--odoo-http]\n\nThe custom options are:\n\n* ``--odoo-database``: name of the database to test.\n* ``--odoo-log-level``: log level as expected by odoo. As time of writing: info, debug_rpc, warn, test, critical, debug_sql, error, debug, debug_rpc_answer. The default is critical to have a clean output.\n* ``--odoo-config``: path of the odoo.cfg file to use.\n* ``--odoo-http``: Allow to launch the Odoo http instance\n\n\nAlternatively, you can use environment variables, like the Odoo Docker image:\n\n* ``HOST``: hostname of the database server\n* ``PORT``: port of the database server\n* ``USER``: username to access the database\n* ``PASSWORD``: password to access the database\n\nThese only work in addition to ``--odoo-database``.\n\nYou can use the ``ODOO_RC`` environment variable using an odoo configuration file, containing at least the ``database`` option with the name of the database to test::\n\n   export ODOO_RC=/path/to/odoo/config.cfg\n   pytest ...\n\n",
    "bugtrack_url": null,
    "license": "AGPLv3",
    "summary": "py.test plugin to run Odoo tests",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/camptocamp/pytest-odoo"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c2207cfaf94c87f33b8bea020da2e7e33d67d4899043263ab3c33618b45dad8",
                "md5": "a8b58a31e1c0ca44544cca35ac5adeb9",
                "sha256": "4fc54ba182a1a0534cc82e4f509d1d8fd87c7605e951630453dd1d111a8af92a"
            },
            "downloads": -1,
            "filename": "pytest_odoo-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a8b58a31e1c0ca44544cca35ac5adeb9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17113,
            "upload_time": "2024-10-06T23:07:07",
            "upload_time_iso_8601": "2024-10-06T23:07:07.921421Z",
            "url": "https://files.pythonhosted.org/packages/1c/22/07cfaf94c87f33b8bea020da2e7e33d67d4899043263ab3c33618b45dad8/pytest_odoo-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9bb397f42423f99370bac1830f7fdc569f59b9a5ec3ff798ef3bf3555d9dbfc",
                "md5": "3bc8e7765d32ccd8942ed1400041b5ef",
                "sha256": "75c9a9b6cedac91d22683f2cfeda0c0c824b0070e7ac2548f76841d5086c2867"
            },
            "downloads": -1,
            "filename": "pytest_odoo-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3bc8e7765d32ccd8942ed1400041b5ef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19240,
            "upload_time": "2024-10-06T23:07:08",
            "upload_time_iso_8601": "2024-10-06T23:07:08.982652Z",
            "url": "https://files.pythonhosted.org/packages/f9/bb/397f42423f99370bac1830f7fdc569f59b9a5ec3ff798ef3bf3555d9dbfc/pytest_odoo-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-06 23:07:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "camptocamp",
    "github_project": "pytest-odoo",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-odoo"
}
        
Elapsed time: 0.31588s