I want to set a variable in my Python code to different values, according to whether it is running in unit tests or in production.
Assuming we can't pass additional parameters to the test runners, or we don't have any environment variables set in production environment.
A_LOCAL_VARIABLE = 1 if is_running_by_pytest() else 0
My expectation is that by checking whether the code is running under the pytest runner, I can change the value of the variable.
Ideally, if the code is ran by the pytest runner, there're some pre-defined environment variables that we can use to identify it. But I cannot find documentations, or I was using the wrong keywords.