How to pass environment variables to pytest

后端 未结 8 738
小鲜肉
小鲜肉 2020-12-05 01:48

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

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 01:54

    Run export inside a subshell (enclosing parenthesis) not to mess up local environment. Supply export with parameters from .env file.

    (export $(xargs < .env); pytest -svvvx api)

提交回复
热议问题