-
I think it's common particularly when deploying services in containers to get some configuration from environment, at the top of a module, like this:
In this use case it's usually too late to use My workaround for this is to rely on the fact that
But it seems a bit off-label usage and I'm not sure if it's actually documented/guaranteed that putting this in I wonder if this is something that we could do in pytest config file directly? There's a plugin pytest-env which is small and simple and does similar:
A concern though is that there's some danger of "production" config values being used if the tests were accidentally run without the plugin installed. Could a feature like this go into pytest directly? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @wimglenn! Integrating |
Beta Was this translation helpful? Give feedback.
-
The concern of interacting with default or externally configured services is mitigated by using the required_plugins setting mentioned in the comments.
That makes the test session abort early if |
Beta Was this translation helpful? Give feedback.
The concern of interacting with default or externally configured services is mitigated by using the required_plugins setting mentioned in the comments.
That makes the test session abort early if
pytest-env
wasn't installed, rather than just print a warning about unrecognized config options.