<s> import email <EOL> import email . errors <EOL> import imp <EOL> import os <EOL> import re <EOL> import sysconfig <EOL> import tempfile <EOL> import textwrap <EOL> import fixtures <EOL> import mock <EOL> import pkg_resources <EOL> import six <EOL> import testtools <EOL> from testtools import matchers <EOL> import virtualenv <EOL> import wheel . install <EOL> from pbr import git <EOL> from pbr import packaging <EOL> from pbr . tests import base <EOL> PBR_ROOT = os . path . abspath ( os . path . join ( __file__ , '<STR_LIT:..>' , '<STR_LIT:..>' , '<STR_LIT:..>' ) ) <EOL> class TestRepo ( fixtures . Fixture ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , basedir ) : <EOL> super ( TestRepo , self ) . __init__ ( ) <EOL> self . _basedir = basedir <EOL> def setUp ( self ) : <EOL> super ( TestRepo , self ) . setUp ( ) <EOL> base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:.>' ] , self . _basedir ) <EOL> base . _config_git ( ) <EOL> base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:.>' ] , self . _basedir ) <EOL> def commit ( self , message_content = '<STR_LIT>' ) : <EOL> files = len ( os . listdir ( self . _basedir ) ) <EOL> path = self . _basedir + '<STR_LIT>' % files <EOL> open ( path , '<STR_LIT>' ) . close ( ) <EOL> base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' , path ] , self . _basedir ) <EOL> base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , message_content ] , self . _basedir ) <EOL> def uncommit ( self ) : <EOL> base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , self . _basedir ) <EOL> def tag ( self , version ) : <EOL> base . _run_cmd ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , version ] , self . _basedir ) <EOL> class GPGKeyFixture ( fixtures . Fixture ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( GPGKeyFixture , self ) . setUp ( ) <EOL> tempdir = self . useFixture ( fixtures . TempDir ( ) ) <EOL> gnupg_version_re = re . compile ( '<STR_LIT>' ) <EOL> gnupg_version = base . _run_cmd ( [ '<STR_LIT>' , '<STR_LIT>' ] , tempdir . path ) <EOL> for line in gnupg_version [ <NUM_LIT:0> ] . split ( '<STR_LIT:\n>' ) : <EOL> gnupg_version = gnupg_version_re . match ( line ) <EOL> if gnupg_version : <EOL> gnupg_version = ( int ( gnupg_version . group ( <NUM_LIT:1> ) ) , <EOL> int ( gnupg_version . group ( <NUM_LIT:2> ) ) , <EOL> int ( gnupg_version . group ( <NUM_LIT:3> ) ) ) <EOL> break <EOL> else : <EOL> if gnupg_version is None : <EOL> gnupg_version = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> config_file = tempdir . path + '<STR_LIT>' <EOL> f = open ( config_file , '<STR_LIT>' ) <EOL> try : <EOL> if gnupg_version [ <NUM_LIT:0> ] == <NUM_LIT:2> and gnupg_version [ <NUM_LIT:1> ] >= <NUM_LIT:1> : <EOL> f . write ( """<STR_LIT>""" ) <EOL> f . write ( """<STR_LIT>""" ) <EOL> finally : <EOL> f . close ( ) <EOL> if gnupg_version [ <NUM_LIT:0> ] == <NUM_LIT:1> : <EOL> gnupg_random = '<STR_LIT>' <EOL> elif gnupg_version [ <NUM_LIT:0> ] >= <NUM_LIT:2> : <EOL> gnupg_random = '<STR_LIT>' <EOL> else : <EOL> gnupg_random = '<STR_LIT>' <EOL> base . _run_cmd ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , gnupg_random , config_file ] , <EOL> tempdir . path ) <EOL> class Venv ( fixtures . Fixture ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , reason , modules = ( ) , pip_cmd = None ) : <EOL> """<STR_LIT>""" <EOL> self . _reason = reason <EOL> if modules == ( ) : <EOL> pbr = '<STR_LIT>' % PBR_ROOT <EOL> modules = [ '<STR_LIT>' , '<STR_LIT>' , pbr ] <EOL> self . modules = modules <EOL> if pip_cmd is None : <EOL> self . pip_cmd = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> else : <EOL> self . pip_cmd = pip_cmd <EOL> def _setUp ( self ) : <EOL> path = self . useFixture ( fixtures . TempDir ( ) ) . path <EOL> virtualenv . create_environment ( path , clear = True ) <EOL> python = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> command = [ python ] + self . pip_cmd + [ '<STR_LIT>' ] <EOL> if self . modules and len ( self . modules ) > <NUM_LIT:0> : <EOL> command . extend ( self . modules ) <EOL> self . useFixture ( base . CapturedSubprocess ( <EOL> '<STR_LIT>' + self . _reason , command ) ) <EOL> self . addCleanup ( delattr , self , '<STR_LIT:path>' ) <EOL> self . addCleanup ( delattr , self , '<STR_LIT>' ) <EOL> self . path = path <EOL> self . python = python <EOL> return path , python <EOL> class CreatePackages ( fixtures . Fixture ) : <EOL> """<STR_LIT>""" <EOL> defaults = { <EOL> '<STR_LIT>' : textwrap . dedent ( six . u ( """<STR_LIT>""" ) ) , <EOL> '<STR_LIT>' : textwrap . dedent ( six . u ( """<STR_LIT>""" ) ) <EOL> } <EOL> def __init__ ( self , packages ) : <EOL> """<STR_LIT>""" <EOL> self . packages = packages <EOL> def _writeFile ( self , directory , file_name , contents ) : <EOL> path = os . path . abspath ( os . path . join ( directory , file_name ) ) <EOL> path_dir = os . path . dirname ( path ) <EOL> if not os . path . exists ( path_dir ) : <EOL> if path_dir . startswith ( directory ) : <EOL> os . makedirs ( path_dir ) <EOL> else : <EOL> raise ValueError <EOL> with open ( path , '<STR_LIT>' ) as f : <EOL> f . write ( contents ) <EOL> def _setUp ( self ) : <EOL> tmpdir = self . useFixture ( fixtures . TempDir ( ) ) . path <EOL> package_dirs = { } <EOL> for pkg_name in self . packages : <EOL> pkg_path = os . path . join ( tmpdir , pkg_name ) <EOL> package_dirs [ pkg_name ] = pkg_path <EOL> os . mkdir ( pkg_path ) <EOL> for cf in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if cf in self . packages [ pkg_name ] : <EOL> contents = self . packages [ pkg_name ] . pop ( cf ) <EOL> else : <EOL> contents = self . defaults [ cf ] . format ( pkg_name = pkg_name ) <EOL> self . _writeFile ( pkg_path , cf , contents ) <EOL> for cf in self . packages [ pkg_name ] : <EOL> self . _writeFile ( pkg_path , cf , self . packages [ pkg_name ] [ cf ] ) <EOL> self . useFixture ( TestRepo ( pkg_path ) ) . commit ( ) <EOL> self . addCleanup ( delattr , self , '<STR_LIT>' ) <EOL> self . package_dirs = package_dirs <EOL> return package_dirs <EOL> class TestPackagingInGitRepoWithCommit ( base . BaseTestCase ) : <EOL> scenarios = [ <EOL> ( '<STR_LIT>' , dict ( preversioned = True ) ) , <EOL> ( '<STR_LIT>' , dict ( preversioned = False ) ) , <EOL> ] <EOL> def setUp ( self ) : <EOL> super ( TestPackagingInGitRepoWithCommit , self ) . setUp ( ) <EOL> repo = self . useFixture ( TestRepo ( self . package_dir ) ) <EOL> repo . commit ( ) <EOL> def test_authors ( self ) : <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> with open ( os . path . join ( self . package_dir , '<STR_LIT>' ) , '<STR_LIT:r>' ) as f : <EOL> body = f . read ( ) <EOL> self . assertNotEqual ( body , '<STR_LIT>' ) <EOL> def test_changelog ( self ) : <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> with open ( os . path . join ( self . package_dir , '<STR_LIT>' ) , '<STR_LIT:r>' ) as f : <EOL> body = f . read ( ) <EOL> self . assertNotEqual ( body , '<STR_LIT>' ) <EOL> def test_manifest_exclude_honoured ( self ) : <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> with open ( os . path . join ( <EOL> self . package_dir , <EOL> '<STR_LIT>' ) , '<STR_LIT:r>' ) as f : <EOL> body = f . read ( ) <EOL> self . assertThat ( <EOL> body , matchers . Not ( matchers . Contains ( '<STR_LIT>' ) ) ) <EOL> self . assertThat ( body , matchers . Contains ( '<STR_LIT>' ) ) <EOL> def test_install_writes_changelog ( self ) : <EOL> stdout , _ , _ = self . run_setup ( <EOL> '<STR_LIT>' , '<STR_LIT>' , self . temp_dir + '<STR_LIT>' , <EOL> allow_fail = False ) <EOL> self . expectThat ( stdout , matchers . Contains ( '<STR_LIT>' ) ) <EOL> class TestPackagingInGitRepoWithoutCommit ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestPackagingInGitRepoWithoutCommit , self ) . setUp ( ) <EOL> self . useFixture ( TestRepo ( self . package_dir ) ) <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> def test_authors ( self ) : <EOL> with open ( os . path . join ( self . package_dir , '<STR_LIT>' ) , '<STR_LIT:r>' ) as f : <EOL> body = f . read ( ) <EOL> self . assertEqual ( body , '<STR_LIT:\n>' ) <EOL> def test_changelog ( self ) : <EOL> with open ( os . path . join ( self . package_dir , '<STR_LIT>' ) , '<STR_LIT:r>' ) as f : <EOL> body = f . read ( ) <EOL> self . assertEqual ( body , '<STR_LIT>' ) <EOL> class TestPackagingWheels ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestPackagingWheels , self ) . setUp ( ) <EOL> self . useFixture ( TestRepo ( self . package_dir ) ) <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> dist_dir = os . path . join ( self . package_dir , '<STR_LIT>' ) <EOL> relative_wheel_filename = os . listdir ( dist_dir ) [ <NUM_LIT:0> ] <EOL> absolute_wheel_filename = os . path . join ( <EOL> dist_dir , relative_wheel_filename ) <EOL> wheel_file = wheel . install . WheelFile ( absolute_wheel_filename ) <EOL> wheel_name = wheel_file . parsed_filename . group ( '<STR_LIT>' ) <EOL> self . extracted_wheel_dir = os . path . join ( dist_dir , wheel_name ) <EOL> wheel_file . zipfile . extractall ( self . extracted_wheel_dir ) <EOL> wheel_file . zipfile . close ( ) <EOL> def test_data_directory_has_wsgi_scripts ( self ) : <EOL> scripts_dir = os . path . join ( <EOL> self . extracted_wheel_dir , '<STR_LIT>' ) <EOL> self . assertTrue ( os . path . exists ( scripts_dir ) ) <EOL> scripts = os . listdir ( scripts_dir ) <EOL> self . assertIn ( '<STR_LIT>' , scripts ) <EOL> self . assertIn ( '<STR_LIT>' , scripts ) <EOL> self . assertNotIn ( '<STR_LIT>' , scripts ) <EOL> self . assertNotIn ( '<STR_LIT>' , scripts ) <EOL> def test_generates_c_extensions ( self ) : <EOL> built_package_dir = os . path . join ( <EOL> self . extracted_wheel_dir , '<STR_LIT>' ) <EOL> static_object_filename = '<STR_LIT>' <EOL> soabi = get_soabi ( ) <EOL> if soabi : <EOL> static_object_filename = '<STR_LIT>' . format ( soabi ) <EOL> static_object_path = os . path . join ( <EOL> built_package_dir , static_object_filename ) <EOL> self . assertTrue ( os . path . exists ( built_package_dir ) ) <EOL> self . assertTrue ( os . path . exists ( static_object_path ) ) <EOL> class TestPackagingHelpers ( testtools . TestCase ) : <EOL> def test_generate_script ( self ) : <EOL> group = '<STR_LIT>' <EOL> entry_point = pkg_resources . EntryPoint ( <EOL> name = '<STR_LIT>' , <EOL> module_name = '<STR_LIT>' , <EOL> attrs = ( '<STR_LIT>' , ) ) <EOL> header = '<STR_LIT>' <EOL> template = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> generated_script = packaging . generate_script ( <EOL> group , entry_point , header , template ) <EOL> expected_script = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( expected_script , generated_script ) <EOL> def test_generate_script_validates_expectations ( self ) : <EOL> group = '<STR_LIT>' <EOL> entry_point = pkg_resources . EntryPoint ( <EOL> name = '<STR_LIT>' , <EOL> module_name = '<STR_LIT>' ) <EOL> header = '<STR_LIT>' <EOL> template = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertRaises ( <EOL> ValueError , packaging . generate_script , group , entry_point , header , <EOL> template ) <EOL> entry_point = pkg_resources . EntryPoint ( <EOL> name = '<STR_LIT>' , <EOL> module_name = '<STR_LIT>' , <EOL> attrs = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertRaises ( <EOL> ValueError , packaging . generate_script , group , entry_point , header , <EOL> template ) <EOL> class TestPackagingInPlainDirectory ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestPackagingInPlainDirectory , self ) . setUp ( ) <EOL> def test_authors ( self ) : <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> filename = os . path . join ( self . package_dir , '<STR_LIT>' ) <EOL> self . assertFalse ( os . path . exists ( filename ) ) <EOL> def test_changelog ( self ) : <EOL> self . run_setup ( '<STR_LIT>' , allow_fail = False ) <EOL> filename = os . path . join ( self . package_dir , '<STR_LIT>' ) <EOL> self . assertFalse ( os . path . exists ( filename ) ) <EOL> def test_install_no_ChangeLog ( self ) : <EOL> stdout , _ , _ = self . run_setup ( <EOL> '<STR_LIT>' , '<STR_LIT>' , self . temp_dir + '<STR_LIT>' , <EOL> allow_fail = False ) <EOL> self . expectThat ( <EOL> stdout , matchers . Not ( matchers . Contains ( '<STR_LIT>' ) ) ) <EOL> class TestPresenceOfGit ( base . BaseTestCase ) : <EOL> def testGitIsInstalled ( self ) : <EOL> with mock . patch . object ( git , <EOL> '<STR_LIT>' ) as _command : <EOL> _command . return_value = '<STR_LIT>' <EOL> self . assertEqual ( True , git . _git_is_installed ( ) ) <EOL> def testGitIsNotInstalled ( self ) : <EOL> with mock . patch . object ( git , <EOL> '<STR_LIT>' ) as _command : <EOL> _command . side_effect = OSError <EOL> self . assertEqual ( False , git . _git_is_installed ( ) ) <EOL> class TestNestedRequirements ( base . BaseTestCase ) : <EOL> def test_nested_requirement ( self ) : <EOL> tempdir = tempfile . mkdtemp ( ) <EOL> requirements = os . path . join ( tempdir , '<STR_LIT>' ) <EOL> nested = os . path . join ( tempdir , '<STR_LIT>' ) <EOL> with open ( requirements , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT>' + nested ) <EOL> with open ( nested , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT>' ) <EOL> result = packaging . parse_requirements ( [ requirements ] ) <EOL> self . assertEqual ( result , [ '<STR_LIT>' ] ) <EOL> class TestVersions ( base . BaseTestCase ) : <EOL> scenarios = [ <EOL> ( '<STR_LIT>' , dict ( preversioned = True ) ) , <EOL> ( '<STR_LIT>' , dict ( preversioned = False ) ) , <EOL> ] <EOL> def setUp ( self ) : <EOL> super ( TestVersions , self ) . setUp ( ) <EOL> self . repo = self . useFixture ( TestRepo ( self . package_dir ) ) <EOL> self . useFixture ( GPGKeyFixture ( ) ) <EOL> self . useFixture ( base . DiveDir ( self . package_dir ) ) <EOL> def test_email_parsing_errors_are_handled ( self ) : <EOL> mocked_open = mock . mock_open ( ) <EOL> with mock . patch ( '<STR_LIT>' , mocked_open ) : <EOL> with mock . patch ( '<STR_LIT>' ) as message_from_file : <EOL> message_from_file . side_effect = [ <EOL> email . errors . MessageError ( '<STR_LIT>' ) , <EOL> { '<STR_LIT:Name>' : '<STR_LIT>' } ] <EOL> version = packaging . _get_version_from_pkg_metadata ( <EOL> '<STR_LIT>' ) <EOL> self . assertTrue ( message_from_file . called ) <EOL> self . assertIsNone ( version ) <EOL> def test_capitalized_headers ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_capitalized_headers_partial ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_tagged_version_has_tag_version ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , version ) <EOL> def test_non_canonical_tagged_version_bump ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_has_dev_version_postversion ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_pre_release_has_pre_dev_version_postversion ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_minor_bump ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_major_bump ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_has_dev_version_preversion ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( '<STR_LIT>' ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_after_pre_has_dev_version_preversion ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( '<STR_LIT>' ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_untagged_version_after_rc_has_dev_version_preversion ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( '<STR_LIT>' ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_preversion_too_low_simple ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> err = self . assertRaises ( <EOL> ValueError , packaging . _get_version_from_git , '<STR_LIT>' ) <EOL> self . assertThat ( err . args [ <NUM_LIT:0> ] , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_preversion_too_low_semver_headers ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> err = self . assertRaises ( <EOL> ValueError , packaging . _get_version_from_git , '<STR_LIT>' ) <EOL> self . assertThat ( err . args [ <NUM_LIT:0> ] , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_get_kwargs_corner_cases ( self ) : <EOL> git_dir = self . repo . _basedir + '<STR_LIT>' <EOL> get_kwargs = lambda tag : packaging . _get_increment_kwargs ( git_dir , tag ) <EOL> def _check_combinations ( tag ) : <EOL> self . repo . commit ( ) <EOL> self . assertEqual ( dict ( ) , get_kwargs ( tag ) ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> self . assertEqual ( dict ( ) , get_kwargs ( tag ) ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> self . assertEqual ( dict ( minor = True ) , get_kwargs ( tag ) ) <EOL> self . repo . uncommit ( ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> self . assertEqual ( dict ( minor = True ) , get_kwargs ( tag ) ) <EOL> self . repo . uncommit ( ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> self . assertEqual ( dict ( major = True ) , get_kwargs ( tag ) ) <EOL> self . repo . commit ( '<STR_LIT>' ) <EOL> self . assertEqual ( dict ( major = True , minor = True ) , get_kwargs ( tag ) ) <EOL> _check_combinations ( '<STR_LIT>' ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> _check_combinations ( '<STR_LIT>' ) <EOL> def test_invalid_tag_ignored ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT:1>' ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> self . repo . commit ( ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT:2>' ) <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertThat ( version , matchers . StartsWith ( '<STR_LIT>' ) ) <EOL> def test_valid_tag_honoured ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> version = packaging . _get_version_from_git ( ) <EOL> self . assertEqual ( '<STR_LIT>' , version ) <EOL> def test_skip_write_git_changelog ( self ) : <EOL> self . repo . commit ( ) <EOL> self . repo . tag ( '<STR_LIT>' ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:1>' <EOL> version = packaging . _get_version_from_git ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , version ) <EOL> def tearDown ( self ) : <EOL> super ( TestVersions , self ) . tearDown ( ) <EOL> os . environ . pop ( '<STR_LIT>' , None ) <EOL> class TestRequirementParsing ( base . BaseTestCase ) : <EOL> def test_requirement_parsing ( self ) : <EOL> pkgs = { <EOL> '<STR_LIT>' : <EOL> { <EOL> '<STR_LIT>' : textwrap . dedent ( """<STR_LIT>""" ) , <EOL> '<STR_LIT>' : textwrap . dedent ( """<STR_LIT>""" ) } , <EOL> } <EOL> pkg_dirs = self . useFixture ( CreatePackages ( pkgs ) ) . package_dirs <EOL> pkg_dir = pkg_dirs [ '<STR_LIT>' ] <EOL> expected_requirements = { <EOL> None : [ '<STR_LIT:bar>' , '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> '<STR_LIT:test>' : [ '<STR_LIT:foo>' ] , <EOL> "<STR_LIT>" : [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> venv = self . useFixture ( Venv ( '<STR_LIT>' ) ) <EOL> bin_python = venv . python <EOL> self . _run_cmd ( bin_python , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> allow_fail = False , cwd = pkg_dir ) <EOL> egg_info = os . path . join ( pkg_dir , '<STR_LIT>' ) <EOL> requires_txt = os . path . join ( egg_info , '<STR_LIT>' ) <EOL> with open ( requires_txt , '<STR_LIT>' ) as requires : <EOL> generated_requirements = dict ( <EOL> pkg_resources . split_sections ( requires ) ) <EOL> self . assertEqual ( expected_requirements , generated_requirements ) <EOL> def get_soabi ( ) : <EOL> try : <EOL> return sysconfig . get_config_var ( '<STR_LIT>' ) <EOL> except IOError : <EOL> pass <EOL> if '<STR_LIT>' in sysconfig . get_scheme_names ( ) : <EOL> for suffix , _ , _ in imp . get_suffixes ( ) : <EOL> if suffix . startswith ( '<STR_LIT>' ) and suffix . endswith ( '<STR_LIT>' ) : <EOL> return suffix . split ( '<STR_LIT:.>' ) [ <NUM_LIT:1> ] <EOL> return None </s>
