- integrations
- Python
- Test against a pinned tool in pytest: Keep the test hermetic
Test against a pinned tool in pytest: Keep the test hermetic
Part 2 of 2 of Test against a pinned tool in pytest.
Keep the test hermetic
Section titled “Keep the test hermetic”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.
See also
Section titled “See also”- Run pinned tools from a script: the calls the factory uses.
- Concurrency and timeouts: sharing one handle across threads.