quiqua / pytest-dotenv

A py.test plugin that parses environment files before running tests
MIT License
189 stars 18 forks source link

Environment variables are not found when pytest is started in shell #11

Closed lgrosser-tiplu closed 4 years ago

lgrosser-tiplu commented 4 years ago

Hi, I am using Pycharm 2019.3.1, the package works great when I start pytest by using right-click on the respective test folder from within Pycharm, all environment variables are found and used. However, if I start pytest from the console, the variables are not found. Am I missing a cli parameter that tells pytest to use pytest-dotenv?

quiqua commented 4 years ago

If you use pytest from the console, do you use a virtualenv and did you install pytest-dotenv to that virtualenv?

You can run pip freeze from the console to see which packages are available to you / have been installed to the current python executable.

lgrosser-tiplu commented 4 years ago

I am using virtualenv and installed pytest-dotenv==0.4.0 to the virtual environment from within I am starting the shell commando.

quiqua commented 4 years ago

Can you provide an example project to replicate this and help you out?

lgrosser-tiplu commented 4 years ago

I just solved it. My pytest.ini and .env file was not in the root directory of the repository. Thank you for this useful plugin. This issue can be closed.

untidy-hair commented 4 years ago

It's good to mention that you can specify dirname/your.env in .ini file, too.