Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Alternatively, you can use environment variables, like the Odoo Docker image:

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

In case these environment variables conflict with your setup, you may use ``--odoo-ignore-env-db-param``.

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
Expand Down
12 changes: 8 additions & 4 deletions pytest_odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def pytest_addoption(parser):
default=[],
help="Extra options to pass to odoo "
"(e.g. --odoo-extra workers=0 --odoo-extra db-filter=odoo_test)")

parser.addoption("--odoo-ignore-env-db-param",
action="store_true",
help="Disable using environment variables for DB parameters "
"(HOST, PORT, USER, PASSWORD)")

@pytest.hookimpl(hookwrapper=True)
def pytest_cmdline_main(config):
Expand Down Expand Up @@ -76,9 +79,10 @@ def pytest_cmdline_main(config):

# Check the environment variables supported by the Odoo Docker image
# ref: https://hub.docker.com/_/odoo
for arg in ['HOST', 'PORT', 'USER', 'PASSWORD']:
if os.environ.get(arg):
options.append('--db_%s=%s' % (arg.lower(), os.environ.get(arg)))
if not config.getoption("--odoo-ignore-env-db-param"):
for arg in ['HOST', 'PORT', 'USER', 'PASSWORD']:
if os.environ.get(arg):
options.append('--db_%s=%s' % (arg.lower(), os.environ.get(arg)))

odoo.tools.config.parse_config(options)

Expand Down