#NEWLINE# def test_write_zipped_internal_cache( ) : #NEWLINE# #INDENT# with nested ( yield_pex_builder ( zip_safe = True ) , temporary_dir ( ) , temporary_filename ( ) ) as ( pb , pex_root , pex_file ) : #NEWLINE# #INDENT# pb . info . pex_root = pex_root #NEWLINE# pb . build ( pex_file ) #NEWLINE# ( existing , new , zip_safe ) = PEXEnvironment . write_zipped_internal_cache ( pex_file , pb . info ) #NEWLINE# assert ( len ( zip_safe ) == 1 ) #NEWLINE# assert normalize ( zip_safe [ 0 ] . location ) . startswith ( normalize ( os . path . join ( pex_file , pb . info . internal_cache ) ) ) , ( 'loc: %s, cache: %s' % ( normalize ( zip_safe [ 0 ] . location ) , normalize ( os . path . join ( pex_file , pb . info . internal_cache ) ) ) ) #NEWLINE# pb . info . always_write_cache = True #NEWLINE# ( existing , new , zip_safe ) = PEXEnvironment . write_zipped_internal_cache ( pex_file , pb . info ) #NEWLINE# assert ( len ( new ) == 1 ) #NEWLINE# assert normalize ( new [ 0 ] . location ) . startswith ( normalize ( pb . info . install_cache ) ) #NEWLINE# ( existing , new , zip_safe ) = PEXEnvironment . write_zipped_internal_cache ( pex_file , pb . info ) #NEWLINE# assert ( len ( existing ) == 1 ) #NEWLINE# assert normalize ( existing [ 0 ] . location ) . startswith ( normalize ( pb . info . install_cache ) ) #NEWLINE# #UNINDENT# with nested ( yield_pex_builder ( zip_safe = False ) , temporary_dir ( ) , temporary_filename ( ) ) as ( pb , pex_root , pex_file ) : #NEWLINE# #INDENT# pb . info . pex_root = pex_root #NEWLINE# pb . build ( new ) #NEWLINE# ( existing , new , zip_safe ) = PEXEnvironment . write_zipped_internal_cache ( pex_file , pb . info ) #NEWLINE# assert ( len ( new ) == 1 ) #NEWLINE# assert normalize ( new [ 0 ] . location ) . startswith ( normalize ( pb . info . install_cache ) ) #NEWLINE# original_location = normalize ( new [ 0 ] . location ) #NEWLINE# ( existing , new , zip_safe ) = PEXEnvironment . write_zipped_internal_cache ( pex_file , pb . info ) #NEWLINE# assert ( len ( existing ) == 1 ) #NEWLINE# assert ( normalize ( existing [ 0 ] . location ) == original_location )