-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rethink how env vars are mocked in tests #316
Comments
Transferred this to n-API because we use env vars here more so far. |
We want to keep our issues up to date and active. This issue hasn't seen any activity in the last 75 days.
|
github-actions
bot
added
the
_flag:stale
[BOT ONLY] Flag issue that hasn't been updated in a while and needs to be triaged again
label
Aug 12, 2024
See also pytest-dev/pytest#10027 (comment) |
alyssadai
added
the
flag:schedule
Flag issue that should go on the roadmap or backlog.
label
Oct 25, 2024
github-actions
bot
removed
the
_flag:stale
[BOT ONLY] Flag issue that hasn't been updated in a while and needs to be triaged again
label
Oct 26, 2024
surchs
removed
the
flag:schedule
Flag issue that should go on the roadmap or backlog.
label
Oct 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
os.env
read?For testing the time at which the env vars are read is at import time as opposed to at app start time/test runtime.
In the n-API (and soon f-API: neurobagel/federation-api#90) we load ENV variables in a utility module like so
api/app/api/utility.py
Lines 16 to 18 in 84c0e99
Because the loading happens at the top level of the module, the ENV variable gets read in when the module is imported. In other words: we have no control over when the ENV variable is read in (e.g. during or after app startup).
This mainly matters during testing where we have to make sure we set ENV variables before the test run starts at all using something like https://pypi.org/project/pytest-env/ because by the time we have launched the TestApp client or imported the utility module any further changes to ENV variables will have no effect (because the reading has already happened).
This has two immediate consequences:
Possible solutions
The text was updated successfully, but these errors were encountered: