I'm using pytest
to run some tests. Is there a way to specify multiple configurations through the pytest.ini?
The reason I need this is that when testing a locally running Lambda, I require some slightly different options than when running in CI pipeline.
For example, to check if tests are being run against a locally running Lambda, I check the value of an environment variable MYFUNCTION_LOCAL
in the setup_class
method of a test class. Additionally there are options such as --color no
that don't necessarily need to be included when testing against a locally running Lambda.
Currently my 'pytest.ini' file looks like this. I can't add MYFUNCTION_LOCAL
because the value will differ depending on where the tests are executed.
[pytest]
addopts = --color no --capture no --verbose
minversion = 7.0
env =
AWS_XRAY_SDK_ENABLED=false
There seems to be the option of using a TOML file, but the documentation suggests that only the tool.pytest.ini_options
table is considered at this time, so I don't think that is an option.
What is the best way to handle scenarios like this with pytest
?