def test_flatten(self) -> None: """Test round-trip Environ('...').expand().flatten().""" # clean environment of any existing variables with the item prefix = 'CMDKIT' for var in dict(os.environ): if var.startswith(prefix): os.environ.pop(var) # populate environment with test variables for line in TEST_ENV_TYPES.strip().split('\n'): field, value = line.strip().split('=') os.environ[field] = value env = Namespace.from_env(prefix) assert env == env.expand().flatten(prefix=prefix)
def test_init(self) -> None: """Test environment variable initialization along with Environ.reduce().""" # clean environment of any existing variables with the item prefix = 'CMDKIT' for var in dict(os.environ): if var.startswith(prefix): os.environ.pop(var) # populate environment with test variables for line in TEST_ENV.strip().split('\n'): field, value = line.strip().split('=') os.environ[field] = value # test base level Namespace|Environ equivalence assert Namespace.from_env(prefix=prefix) == Environ(prefix=prefix) assert Environ(prefix=prefix).expand() == Namespace(TEST_DICT)