def test_force_local(): with nested(yield_pex_builder(), temporary_dir(), temporary_file()) as (pb, pex_root, pex_file): pex = pb.path() pb.info.pex_root = pex_root pb.build(pex_file.name) code_cache = PEXEnvironment.force_local(pex_file.name, pb.info) assert os.path.exists(pb.info.zip_unsafe_cache) assert len(os.listdir(pb.info.zip_unsafe_cache)) == 1 assert [os.path.basename(code_cache)] == os.listdir(pb.info.zip_unsafe_cache) assert set(os.listdir(code_cache)) == set([PexInfo.PATH, '__main__.py']) # idempotence assert PEXEnvironment.force_local(pex_file.name, pb.info) == code_cache