cornsnake.util_env

Utility functions for environment detection.

Documentation

 1"""
 2Utility functions for environment detection.
 3
 4[Documentation](http://docs.mrseanryan.cornsnake.s3-website-eu-west-1.amazonaws.com/cornsnake/util_env.html)
 5"""
 6
 7from pathlib import Path
 8import sys
 9
10
11def is_in_docker() -> bool:
12    """Check if the code is running inside a Docker container."""
13    return Path("/.dockerenv").exists()
14
15
16def is_in_a_test() -> bool:
17    """Check if the code is running inside a test framework."""
18    return "pytest" in sys.modules or "unittest" in sys.modules
def is_in_docker() -> bool:
12def is_in_docker() -> bool:
13    """Check if the code is running inside a Docker container."""
14    return Path("/.dockerenv").exists()

Check if the code is running inside a Docker container.

def is_in_a_test() -> bool:
17def is_in_a_test() -> bool:
18    """Check if the code is running inside a test framework."""
19    return "pytest" in sys.modules or "unittest" in sys.modules

Check if the code is running inside a test framework.