Skip to content
ocx
install

Test against a pinned tool in pytest: Keep the test hermetic

Part 2 of 2 of Test against a pinned tool in pytest.

Point the handle at a throwaway store and drop the ambient environment, so a developer’s shell cannot change the result:

from ocx_sdk import HostEnv, OcxConfig
hermetic = Ocx(
config=OcxConfig(home=Path(tempfile.mkdtemp())),
host_env=HostEnv.minimal(),
)
print(hermetic.version())

HostEnv.minimal() keeps only PATH, HOME and TMPDIR. See Hermetic CI for the other levers.