Skip to content

add flag to disable environment variables#83

Open
theverygaming wants to merge 1 commit into
camptocamp:masterfrom
theverygaming:fix-env
Open

add flag to disable environment variables#83
theverygaming wants to merge 1 commit into
camptocamp:masterfrom
theverygaming:fix-env

Conversation

@theverygaming

Copy link
Copy Markdown

I added a flag --odoo-disable-docker-env that allows disabling the HOST PORT USER and PASSWORD environment variables added in #57 as they may conflict with environment variables in some development setups (mainly USER is extremely common to be set)

If there are any improvements needed for this to get merged, please do tell - I'd love to see this issue fixed as currently it makes pytest-odoo unusable without patches for me with my setup...

closes: #81

@petrus-v petrus-v left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm not using this feature as well and could effectively create unexpected behaviour if those env names are set which are very common name...

I would love to see PYTEST-ODOO-DB- prefix but this would breaks existing workflow. I believes your solution seems fine.

Maybe we could add a deprecation warning in the same time that suggest to move to the new environ names (with suggest prefix) in the current version and prepare next major release that remove support for those env names

@simahawk what's your call on this ?

Comment thread pytest_odoo.py Outdated
@florentx

Copy link
Copy Markdown
Contributor

If there are any improvements needed for this to get merged, please do tell - I'd love to see this issue fixed as currently it makes pytest-odoo unusable without patches for me with my setup...

I would suggest as an alternative, to nullify environment variable in the line which executes pytest.
Something like:

$ USER=  pytest -s --odoo-database=test --odoo-log-level=debug_sql

@theverygaming

Copy link
Copy Markdown
Author

I would suggest as an alternative, to nullify environment variable in the line which executes pytest.

Consider that it's not always easily possible to do that, especially with IDEs!
Also especially since the environment variable USER is extremely common, and commonly used.. This may cause other issues!

Also according to POSIX...

It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters and applications

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

@petrus-v

Copy link
Copy Markdown
Contributor

@unki2aut as you implement #57 your input could be interesting, how much it would breaks your workflow if we change variables names ?

@rvalyi

rvalyi commented Jul 21, 2025

Copy link
Copy Markdown

just to let you know this issue just caught me, indeed my USER env var was set. not sure if this PR is a best option but I think the issue will block many people. Eventually we could have a try/except telling it took user from USER in case of database connection failure and suggest to set USER or use this new --odoo-disable-docker-env option.

@jhuber-de

Copy link
Copy Markdown

I stumbled upon this exact issue, anything I could contribute to help you all getting this merged?

@simahawk

simahawk commented Jan 9, 2026

Copy link
Copy Markdown
Member

I never had this issue. Ideally I would make this the default, and then use like --odoo-db-use-env-vars to make it explicit or an env var that you can easily set in your compose file or running the command: PYTEST_DB_ENV_VARS=True. I tend to prefer the second one.

WDYT?

@theverygaming

Copy link
Copy Markdown
Author

So you propose making it an enable flag instead of a disable flag (as it is now in the PR)? I would be fine with that (I prefer it even^^)

Of course that will likely break the setup of the people who implemented this feature in the first place... But it would restore normal behavior as one expects (not using a very common POSIX environment variable for another purpose)

I do like the environment variable idea, it allows the user to easily set it in the same place where they also set HOST and friends. We could also do both the environment variable and the command line switch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

USER environment variable issues

6 participants