Internal Testing Modules

test.support.os_helper

Filesystem and environment fixtures for CPython tests. temp_dir provides temporary directory cleanup; EnvironmentVarGuard restores tracked environment edits on context exit. Environment changes affect process-wide state and are inappropriate for concurrent uncoordinated tests. This is CPython test infrastructure, not a supported application dependency; prefer public unittest or standard-library equivalents in application tests.

Formal Syntax & Structure

python syntaxpython
import test.support.os_helper

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from test.support.os_helper import temp_dirfrom pathlib import Pathwith temp_dir() as folder:    print(Path(folder).is_dir())print(Path(folder).exists())
Python Reference