<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import unittest <EOL> import codecs <EOL> import subprocess <EOL> from setuptools . tests import environment <EOL> from setuptools . compat import unicode , unichr <EOL> from setuptools import svn_utils <EOL> from setuptools . tests . py26compat import skipIf <EOL> def _do_svn_check ( ) : <EOL> try : <EOL> subprocess . check_call ( [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> shell = ( sys . platform == '<STR_LIT:win32>' ) ) <EOL> return True <EOL> except ( OSError , subprocess . CalledProcessError ) : <EOL> return False <EOL> _svn_check = _do_svn_check ( ) <EOL> class TestSvnVersion ( unittest . TestCase ) : <EOL> def test_no_svn_found ( self ) : <EOL> path_variable = None <EOL> for env in os . environ : <EOL> if env . lower ( ) == '<STR_LIT:path>' : <EOL> path_variable = env <EOL> if path_variable is None : <EOL> try : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> except AttributeError : <EOL> return <EOL> old_path = os . environ [ path_variable ] <EOL> os . environ [ path_variable ] = '<STR_LIT>' <EOL> try : <EOL> version = svn_utils . SvnInfo . get_svn_version ( ) <EOL> self . assertEqual ( version , '<STR_LIT>' ) <EOL> finally : <EOL> os . environ [ path_variable ] = old_path <EOL> @ skipIf ( not _svn_check , "<STR_LIT>" ) <EOL> def test_svn_should_exist ( self ) : <EOL> version = svn_utils . SvnInfo . get_svn_version ( ) <EOL> self . assertNotEqual ( version , '<STR_LIT>' ) <EOL> def _read_utf8_file ( path ) : <EOL> fileobj = None <EOL> try : <EOL> fileobj = codecs . open ( path , '<STR_LIT:r>' , '<STR_LIT:utf-8>' ) <EOL> data = fileobj . read ( ) <EOL> return data <EOL> finally : <EOL> if fileobj : <EOL> fileobj . close ( ) <EOL> class ParserInfoXML ( unittest . TestCase ) : <EOL> def parse_tester ( self , svn_name , ext_spaces ) : <EOL> path = os . path . join ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , svn_name + '<STR_LIT>' ) <EOL> example_base = "<STR_LIT>" % svn_name <EOL> data = _read_utf8_file ( path ) <EOL> expected = set ( [ <EOL> ( "<STR_LIT:\\>" . join ( ( example_base , '<STR_LIT>' ) ) , '<STR_LIT:file>' ) , <EOL> ( "<STR_LIT:\\>" . join ( ( example_base , '<STR_LIT>' ) ) , '<STR_LIT>' ) , <EOL> ( "<STR_LIT:\\>" . join ( ( example_base , '<STR_LIT>' , '<STR_LIT>' ) ) , '<STR_LIT:file>' ) , <EOL> ( "<STR_LIT:\\>" . join ( ( example_base , '<STR_LIT>' , '<STR_LIT>' ) ) , '<STR_LIT:file>' ) , <EOL> ] ) <EOL> self . assertEqual ( set ( x for x in svn_utils . parse_dir_entries ( data ) ) , <EOL> expected ) <EOL> def test_svn13 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn14 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn15 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn16 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn17 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn18 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> class ParserExternalXML ( unittest . TestCase ) : <EOL> def parse_tester ( self , svn_name , ext_spaces ) : <EOL> path = os . path . join ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , svn_name + '<STR_LIT>' ) <EOL> example_base = svn_name + '<STR_LIT>' <EOL> data = _read_utf8_file ( path ) <EOL> if ext_spaces : <EOL> folder2 = '<STR_LIT>' <EOL> folder3 = '<STR_LIT>' <EOL> else : <EOL> folder2 = '<STR_LIT>' <EOL> folder3 = '<STR_LIT>' <EOL> expected = set ( [ <EOL> os . sep . join ( ( example_base , folder2 ) ) , <EOL> os . sep . join ( ( example_base , folder3 ) ) , <EOL> os . sep . join ( ( example_base , <EOL> unicode ( '<STR_LIT>' ) + <EOL> unichr ( <NUM_LIT> ) + unichr ( <NUM_LIT> ) ) ) , <EOL> os . sep . join ( ( example_base , '<STR_LIT>' , folder2 ) ) , <EOL> os . sep . join ( ( example_base , '<STR_LIT>' , folder3 ) ) , <EOL> os . sep . join ( ( example_base , '<STR_LIT>' , <EOL> unicode ( '<STR_LIT>' ) + <EOL> unichr ( <NUM_LIT> ) + unichr ( <NUM_LIT> ) ) ) , <EOL> ] ) <EOL> expected = set ( os . path . normpath ( x ) for x in expected ) <EOL> dir_base = os . sep . join ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( set ( x for x <EOL> in svn_utils . parse_externals_xml ( data , dir_base ) ) , expected ) <EOL> def test_svn15 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn16 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn17 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn18 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> class ParseExternal ( unittest . TestCase ) : <EOL> def parse_tester ( self , svn_name , ext_spaces ) : <EOL> path = os . path . join ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , svn_name + '<STR_LIT>' ) <EOL> data = _read_utf8_file ( path ) <EOL> if ext_spaces : <EOL> expected = set ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> else : <EOL> expected = set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( set ( x for x in svn_utils . parse_external_prop ( data ) ) , <EOL> expected ) <EOL> def test_svn13 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn14 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn15 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , False ) <EOL> def test_svn16 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn17 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> def test_svn18 ( self ) : <EOL> self . parse_tester ( '<STR_LIT>' , True ) <EOL> class TestSvn ( environment . ZippedEnvironment ) : <EOL> def setUp ( self ) : <EOL> version = svn_utils . SvnInfo . get_svn_version ( ) <EOL> if not version : <EOL> self . dataname = None <EOL> self . datafile = None <EOL> return <EOL> self . base_version = tuple ( [ int ( x ) for x in version . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:2> ] ] ) <EOL> if self . base_version < ( <NUM_LIT:1> , <NUM_LIT:3> ) : <EOL> raise ValueError ( '<STR_LIT>' % version ) <EOL> elif self . base_version >= ( <NUM_LIT:1> , <NUM_LIT:9> ) : <EOL> self . base_version = ( <NUM_LIT:1> , <NUM_LIT:8> ) <EOL> self . dataname = "<STR_LIT>" % self . base_version <EOL> self . datafile = os . path . join ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , self . dataname + "<STR_LIT>" ) <EOL> super ( TestSvn , self ) . setUp ( ) <EOL> @ skipIf ( not _svn_check , "<STR_LIT>" ) <EOL> def test_revision ( self ) : <EOL> rev = svn_utils . SvnInfo . load ( '<STR_LIT:.>' ) . get_revision ( ) <EOL> self . assertEqual ( rev , <NUM_LIT:6> ) <EOL> @ skipIf ( not _svn_check , "<STR_LIT>" ) <EOL> def test_entries ( self ) : <EOL> expected = set ( [ <EOL> ( os . path . join ( '<STR_LIT>' ) , '<STR_LIT:file>' ) , <EOL> ( os . path . join ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:file>' ) , <EOL> ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:file>' ) , <EOL> ] ) <EOL> info = svn_utils . SvnInfo . load ( '<STR_LIT:.>' ) <EOL> self . assertEqual ( set ( x for x in info . entries ) , expected ) <EOL> @ skipIf ( not _svn_check , "<STR_LIT>" ) <EOL> def test_externals ( self ) : <EOL> if self . base_version >= ( <NUM_LIT:1> , <NUM_LIT:6> ) : <EOL> folder2 = '<STR_LIT>' <EOL> folder3 = '<STR_LIT>' <EOL> else : <EOL> folder2 = '<STR_LIT>' <EOL> folder3 = '<STR_LIT>' <EOL> expected = set ( [ <EOL> os . path . join ( folder2 ) , <EOL> os . path . join ( folder3 ) , <EOL> os . path . join ( '<STR_LIT>' ) , <EOL> os . path . join ( '<STR_LIT>' , folder2 ) , <EOL> os . path . join ( '<STR_LIT>' , folder3 ) , <EOL> os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> info = svn_utils . SvnInfo . load ( '<STR_LIT:.>' ) <EOL> self . assertEqual ( set ( [ x for x in info . externals ] ) , expected ) <EOL> def test_suite ( ) : <EOL> return unittest . defaultTestLoader . loadTestsFromName ( __name__ ) </s>
