Before I start executing the tests in my Python project, I read some environment variables and set some variables with these values read. My tests will run on the desired en
In addition to other answers. There is an option to overwrite pytest_generate_tests in conftest.py and set ENV variables there.
For example, add following into conftest.py:
import os
def pytest_generate_tests(metafunc):
os.environ['TEST_NAME'] = 'My super test name| Python version {}'.format(python_version)
This code will allow you to grab TEST_NAME ENV variable in your tests application. Also you could make a fixture:
import os
import pytest
@pytest.fixture
def the_name():
return os.environ.get('TEST_NAME')
Also, this ENV variable will be available in your application.