Example for using pyproject.toml for setting env vars

See original GitHub issue

Thanks for creating and maintaining this package!

Can you please provide an example of using this library with pyproject.toml files that pytest config supports? Neither of the below work. 1:

[tool.pytest.ini_options]
env =[
    "HOME=~/tmp",
    "RUN_ENV=test"
]

2:

[tool.pytest.ini_options]
env ="HOME=~/tmp\nRUN_ENV=test"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
setu4993commented, Nov 9, 2020

Thanks @nermand and @bosatsu! Good pointers. I can confirm that any of the below work without python-dotenv or pytest-dotenv: 1.

[tool.pytest.ini_options]
env = [
 "HOME=~/tmp",
 "RUN_ENV=test"
]
[tool.pytest.ini_options]
env ="HOME=~/tmp\nRUN_ENV=test"
[tool.pytest.ini_options]
env = """
    HOME=~/tmp
    RUN_ENV=test
"""

If it doesn’t recommend rechecking the pytest version. My pytest version was downgraded to <6.0, without me noticing, and since pyproject.toml support was added in 6.0+, it wasn’t working.

1reaction
bosatsucommented, Nov 6, 2020

@setu4993

The following works for me, and I’m not using python-dotenv:

[tool.pytest.ini_options]
env = '''
    HOME=~/tmp
    RUN_ENV=test
'''
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add support for environment variables at pyproject.toml #208
The use case I have is that I need to use different repository urls depending on my environment. Something like: [[tool.poetry.source]] name =...
Read more >
envtoml - PyPI
A simple way of using environment variables in TOML configs (via interpolation)
Read more >
Configuration | Documentation | Poetry - Python dependency ...
Poetry supports this and any setting can be set by using environment variables. The environment variables must be prefixed by POETRY_ and are...
Read more >
How to insert test-time environment variable with pytest ...
The correct format is: env = [ "DATA_DIR = data/test_assets", "ROSETTA = rosetta/main" ].
Read more >
config - pypyr
Configure pypyr task-runner run-time settings & defaults with pyproject.toml or the yaml config file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found