<s> """<STR_LIT>""" <EOL> import os <EOL> import pytest <EOL> from mock import patch , Mock <EOL> from pip . _vendor . packaging . requirements import Requirement <EOL> from pip import pep425tags , wheel <EOL> from pip . compat import expanduser , WINDOWS <EOL> from pip . exceptions import InvalidWheelFilename , UnsupportedWheel <EOL> from pip . utils import unpack_file <EOL> def test_get_entrypoints ( tmpdir ) : <EOL> with open ( str ( tmpdir . join ( "<STR_LIT>" ) ) , "<STR_LIT:w>" ) as fp : <EOL> fp . write ( """<STR_LIT>""" ) <EOL> assert wheel . get_entrypoints ( str ( tmpdir . join ( "<STR_LIT>" ) ) ) == ( <EOL> { "<STR_LIT>" : "<STR_LIT>" } , <EOL> { } , <EOL> ) <EOL> def test_uninstallation_paths ( ) : <EOL> class dist ( object ) : <EOL> def get_metadata_lines ( self , record ) : <EOL> return [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> location = '<STR_LIT>' <EOL> d = dist ( ) <EOL> paths = list ( wheel . uninstallation_paths ( d ) ) <EOL> expected = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> assert paths == expected <EOL> paths2 = list ( wheel . uninstallation_paths ( d ) ) <EOL> assert paths2 == paths <EOL> def test_wheel_version ( tmpdir , data ) : <EOL> future_wheel = '<STR_LIT>' <EOL> broken_wheel = '<STR_LIT>' <EOL> future_version = ( <NUM_LIT:1> , <NUM_LIT:9> ) <EOL> unpack_file ( data . packages . join ( future_wheel ) , <EOL> tmpdir + '<STR_LIT>' , None , None ) <EOL> unpack_file ( data . packages . join ( broken_wheel ) , <EOL> tmpdir + '<STR_LIT>' , None , None ) <EOL> assert wheel . wheel_version ( tmpdir + '<STR_LIT>' ) == future_version <EOL> assert not wheel . wheel_version ( tmpdir + '<STR_LIT>' ) <EOL> def test_check_compatibility ( ) : <EOL> name = '<STR_LIT:test>' <EOL> vc = wheel . VERSION_COMPATIBLE <EOL> higher_v = ( vc [ <NUM_LIT:0> ] + <NUM_LIT:1> , vc [ <NUM_LIT:1> ] ) <EOL> with pytest . raises ( UnsupportedWheel ) as e : <EOL> wheel . check_compatibility ( higher_v , name ) <EOL> assert '<STR_LIT>' in str ( e ) <EOL> higher_v = ( vc [ <NUM_LIT:0> ] , vc [ <NUM_LIT:1> ] + <NUM_LIT:1> ) <EOL> wheel . check_compatibility ( higher_v , name ) <EOL> wheel . check_compatibility ( wheel . VERSION_COMPATIBLE , name ) <EOL> lower_v = ( vc [ <NUM_LIT:0> ] , max ( <NUM_LIT:0> , vc [ <NUM_LIT:1> ] - <NUM_LIT:1> ) ) <EOL> wheel . check_compatibility ( lower_v , name ) <EOL> class TestWheelFile ( object ) : <EOL> def test_std_wheel_pattern ( self ) : <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . name == '<STR_LIT>' <EOL> assert w . version == '<STR_LIT>' <EOL> assert w . pyversions == [ '<STR_LIT>' ] <EOL> assert w . abis == [ '<STR_LIT:none>' ] <EOL> assert w . plats == [ '<STR_LIT>' ] <EOL> def test_wheel_pattern_multi_values ( self ) : <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . name == '<STR_LIT>' <EOL> assert w . version == '<STR_LIT>' <EOL> assert w . pyversions == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert w . abis == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert w . plats == [ '<STR_LIT>' ] <EOL> def test_wheel_with_build_tag ( self ) : <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . name == '<STR_LIT>' <EOL> assert w . version == '<STR_LIT>' <EOL> assert w . pyversions == [ '<STR_LIT>' ] <EOL> assert w . abis == [ '<STR_LIT:none>' ] <EOL> assert w . plats == [ '<STR_LIT>' ] <EOL> def test_single_digit_version ( self ) : <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . version == '<STR_LIT:1>' <EOL> def test_missing_version_raises ( self ) : <EOL> with pytest . raises ( InvalidWheelFilename ) : <EOL> wheel . Wheel ( '<STR_LIT>' ) <EOL> def test_invalid_filename_raises ( self ) : <EOL> with pytest . raises ( InvalidWheelFilename ) : <EOL> wheel . Wheel ( '<STR_LIT>' ) <EOL> def test_supported_single_version ( self ) : <EOL> """<STR_LIT>""" <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = [ ( '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' ) ] ) <EOL> def test_supported_multi_version ( self ) : <EOL> """<STR_LIT>""" <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = [ ( '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' ) ] ) <EOL> def test_not_supported_version ( self ) : <EOL> """<STR_LIT>""" <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert not w . supported ( tags = [ ( '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' ) ] ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> def test_supported_osx_version ( self ) : <EOL> """<STR_LIT>""" <EOL> tags = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = tags ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = tags ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> def test_not_supported_osx_version ( self ) : <EOL> """<STR_LIT>""" <EOL> tags = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert not w . supported ( tags = tags ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> def test_supported_multiarch_darwin ( self ) : <EOL> """<STR_LIT>""" <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> universal = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> intel = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> x64 = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> i386 = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> ppc = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> ppc64 = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = intel ) <EOL> assert w . supported ( tags = x64 ) <EOL> assert w . supported ( tags = i386 ) <EOL> assert not w . supported ( tags = universal ) <EOL> assert not w . supported ( tags = ppc ) <EOL> assert not w . supported ( tags = ppc64 ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . supported ( tags = universal ) <EOL> assert w . supported ( tags = intel ) <EOL> assert w . supported ( tags = x64 ) <EOL> assert w . supported ( tags = i386 ) <EOL> assert w . supported ( tags = ppc ) <EOL> assert w . supported ( tags = ppc64 ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda : '<STR_LIT>' ) <EOL> def test_not_supported_multiarch_darwin ( self ) : <EOL> """<STR_LIT>""" <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> universal = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> with patch ( '<STR_LIT>' , <EOL> lambda : '<STR_LIT>' ) : <EOL> intel = pep425tags . get_supported ( [ '<STR_LIT>' ] , False ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert not w . supported ( tags = intel ) <EOL> assert not w . supported ( tags = universal ) <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert not w . supported ( tags = intel ) <EOL> assert not w . supported ( tags = universal ) <EOL> def test_support_index_min ( self ) : <EOL> """<STR_LIT>""" <EOL> tags = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:none>' , '<STR_LIT>' ) , <EOL> ] <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . support_index_min ( tags = tags ) == <NUM_LIT:2> <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . support_index_min ( tags = tags ) == <NUM_LIT:0> <EOL> def test_support_index_min_none ( self ) : <EOL> """<STR_LIT>""" <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . support_index_min ( tags = [ ] ) is None <EOL> def test_unpack_wheel_no_flatten ( self ) : <EOL> from pip import utils <EOL> from tempfile import mkdtemp <EOL> from shutil import rmtree <EOL> filepath = '<STR_LIT>' <EOL> if not os . path . exists ( filepath ) : <EOL> pytest . skip ( "<STR_LIT>" % filepath ) <EOL> try : <EOL> tmpdir = mkdtemp ( ) <EOL> utils . unpack_file ( filepath , tmpdir , '<STR_LIT>' , None ) <EOL> assert os . path . isdir ( os . path . join ( tmpdir , '<STR_LIT>' ) ) <EOL> finally : <EOL> rmtree ( tmpdir ) <EOL> pass <EOL> def test_purelib_platlib ( self , data ) : <EOL> """<STR_LIT>""" <EOL> packages = [ <EOL> ( "<STR_LIT>" , data . packages . join ( "<STR_LIT>" ) , True ) , <EOL> ( "<STR_LIT>" , data . packages . join ( "<STR_LIT>" ) , False ) , <EOL> ] <EOL> for name , path , expected in packages : <EOL> assert wheel . root_is_purelib ( name , path ) == expected <EOL> def test_version_underscore_conversion ( self ) : <EOL> """<STR_LIT>""" <EOL> w = wheel . Wheel ( '<STR_LIT>' ) <EOL> assert w . version == '<STR_LIT>' <EOL> class TestMoveWheelFiles ( object ) : <EOL> """<STR_LIT>""" <EOL> def prep ( self , data , tmpdir ) : <EOL> self . name = '<STR_LIT>' <EOL> self . wheelpath = data . packages . join ( <EOL> '<STR_LIT>' ) <EOL> self . req = Requirement ( '<STR_LIT>' ) <EOL> self . src = os . path . join ( tmpdir , '<STR_LIT:src>' ) <EOL> self . dest = os . path . join ( tmpdir , '<STR_LIT>' ) <EOL> unpack_file ( self . wheelpath , self . src , None , None ) <EOL> self . scheme = { <EOL> '<STR_LIT>' : os . path . join ( self . dest , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : os . path . join ( self . dest , '<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : os . path . join ( self . dest , '<STR_LIT:data>' ) , <EOL> } <EOL> self . src_dist_info = os . path . join ( <EOL> self . src , '<STR_LIT>' ) <EOL> self . dest_dist_info = os . path . join ( <EOL> self . scheme [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def assert_installed ( self ) : <EOL> assert os . path . isdir ( <EOL> os . path . join ( self . scheme [ '<STR_LIT>' ] , '<STR_LIT>' ) ) <EOL> metadata = os . path . join ( self . dest_dist_info , '<STR_LIT>' ) <EOL> assert os . path . isfile ( metadata ) <EOL> data_file = os . path . join ( self . scheme [ '<STR_LIT:data>' ] , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert os . path . isfile ( data_file ) <EOL> pkg_data = os . path . join ( <EOL> self . scheme [ '<STR_LIT>' ] , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert os . path . isfile ( pkg_data ) <EOL> def test_std_install ( self , data , tmpdir ) : <EOL> self . prep ( data , tmpdir ) <EOL> wheel . move_wheel_files ( <EOL> self . name , self . req , self . src , scheme = self . scheme ) <EOL> self . assert_installed ( ) <EOL> def test_install_prefix ( self , data , tmpdir ) : <EOL> prefix = os . path . join ( os . path . sep , '<STR_LIT>' , '<STR_LIT:path>' ) <EOL> self . prep ( data , tmpdir ) <EOL> wheel . move_wheel_files ( <EOL> self . name , <EOL> self . req , <EOL> self . src , <EOL> root = tmpdir , <EOL> prefix = prefix , <EOL> ) <EOL> bin_dir = '<STR_LIT>' if WINDOWS else '<STR_LIT>' <EOL> assert os . path . exists ( os . path . join ( tmpdir , '<STR_LIT>' , '<STR_LIT:path>' , bin_dir ) ) <EOL> assert os . path . exists ( os . path . join ( tmpdir , '<STR_LIT>' , '<STR_LIT:path>' , '<STR_LIT>' ) ) <EOL> def test_dist_info_contains_empty_dir ( self , data , tmpdir ) : <EOL> """<STR_LIT>""" <EOL> self . prep ( data , tmpdir ) <EOL> src_empty_dir = os . path . join ( <EOL> self . src_dist_info , '<STR_LIT>' , '<STR_LIT>' ) <EOL> os . makedirs ( src_empty_dir ) <EOL> assert os . path . isdir ( src_empty_dir ) <EOL> wheel . move_wheel_files ( <EOL> self . name , self . req , self . src , scheme = self . scheme ) <EOL> self . assert_installed ( ) <EOL> assert not os . path . isdir ( <EOL> os . path . join ( self . dest_dist_info , '<STR_LIT>' ) ) <EOL> class TestWheelBuilder ( object ) : <EOL> def test_skip_building_wheels ( self , caplog ) : <EOL> with patch ( '<STR_LIT>' ) as mock_build_one : <EOL> wheel_req = Mock ( is_wheel = True , editable = False , constraint = False ) <EOL> reqset = Mock ( requirements = Mock ( values = lambda : [ wheel_req ] ) , <EOL> wheel_download_dir = '<STR_LIT>' ) <EOL> wb = wheel . WheelBuilder ( reqset , Mock ( ) ) <EOL> wb . build ( ) <EOL> assert "<STR_LIT>" in caplog . text ( ) <EOL> assert mock_build_one . mock_calls == [ ] <EOL> def test_skip_building_editables ( self , caplog ) : <EOL> with patch ( '<STR_LIT>' ) as mock_build_one : <EOL> editable = Mock ( editable = True , is_wheel = False , constraint = False ) <EOL> reqset = Mock ( requirements = Mock ( values = lambda : [ editable ] ) , <EOL> wheel_download_dir = '<STR_LIT>' ) <EOL> wb = wheel . WheelBuilder ( reqset , Mock ( ) ) <EOL> wb . build ( ) <EOL> assert "<STR_LIT>" in caplog . text ( ) <EOL> assert mock_build_one . mock_calls == [ ] <EOL> class TestWheelCache : <EOL> def test_expands_path ( self ) : <EOL> wc = wheel . WheelCache ( "<STR_LIT>" , None ) <EOL> assert wc . _cache_dir == expanduser ( "<STR_LIT>" ) <EOL> def test_falsey_path_none ( self ) : <EOL> wc = wheel . WheelCache ( False , None ) <EOL> assert wc . _cache_dir is None </s>
