Among other things, it can be used to check if a code is running from within a pytest session. Fixes #9502