Once load_dotenv() has run, variables are set. To remove them again for unit testing, I need a function, because tests should be independent. I coded this function already, but I think it would be nice to have it included in dotenv. I guess, I'm not the only one with the described problem. But maybe I'm wrong. I stepped over this more than once now. That's why I'm suggesting adding this function:
def unload_dotenv():
"""Remove all dotenv variables from environment."""
dotenv_vars = set(dotenv_values().keys())
for key in dotenv_vars:
os.environ.pop(key, None)