This adds Testo.with_environment_variables which allows for consistent results for tests that are sensitive to environment variables:
This sets environment variables for the duration of a test and restores the old value when done.
This makes the test fail if one of the specified environment variables is modified without being restored. Unfortunately, this doesn't apply to all the environment variables because I don't know how to obtain the full of list of environment variables. (I now know how to check the whole environment using Unix.environment () but I don't think it's something we need now or that needs to be in testo)
Context: I'm still battling weird errors in semgrep tests, one of them having to do with semgrep app tokens. I'm hoping that setting the environment variable SEMGREP_APP_TOKEN to something will result in the same logs on all machines.
PR checklist:
[x] Purpose of the code is evident to future readers
[x] Tests are included or a PR comment includes a reproducible test plan
[x] Documentation is up-to-date
[ ] A changelog entry was added to CHANGES.md for any user-facing change
This adds
Testo.with_environment_variables
which allows for consistent results for tests that are sensitive to environment variables:Unfortunately, this doesn't apply to all the environment variables because I don't know how to obtain the full of list of environment variables.(I now know how to check the whole environment usingUnix.environment ()
but I don't think it's something we need now or that needs to be in testo)Context: I'm still battling weird errors in semgrep tests, one of them having to do with semgrep app tokens. I'm hoping that setting the environment variable
SEMGREP_APP_TOKEN
to something will result in the same logs on all machines.PR checklist:
CHANGES.md
for any user-facing changeCheck out
CONTRIBUTING.md
for more details.