I am trying to add env variables to pytest. I have successfully managed to add env and configure for regular python scripts but i am unable to use env vars for pytest.
somefile.env
KEY = "12345"
Config.py
import os
headers = {"Key": os.environ.get("KEY"), "content_Type": "application/json"}
Above are the values given in .env and config file. I can access headers value in python script, but i am unable to access this header value inside pytest. Eg this is my code in pytest
import os
from config import headers
print(headers) #---> as this works as expected and prints key value
#Pytests starts
def test_one():
print(headers) # prints key as None
When i call headers in pytest i am getting key value as None