<s> """<STR_LIT>""" <EOL> import os <EOL> import unittest <EOL> from distutils . command . build_scripts import build_scripts <EOL> from distutils . core import Distribution <EOL> import sysconfig <EOL> from distutils . tests import support <EOL> from test . test_support import run_unittest <EOL> class BuildScriptsTestCase ( support . TempdirManager , <EOL> support . LoggingSilencer , <EOL> unittest . TestCase ) : <EOL> def test_default_settings ( self ) : <EOL> cmd = self . get_build_scripts_cmd ( "<STR_LIT>" , [ ] ) <EOL> self . assertTrue ( not cmd . force ) <EOL> self . assertTrue ( cmd . build_dir is None ) <EOL> cmd . finalize_options ( ) <EOL> self . assertTrue ( cmd . force ) <EOL> self . assertEqual ( cmd . build_dir , "<STR_LIT>" ) <EOL> def test_build ( self ) : <EOL> source = self . mkdtemp ( ) <EOL> target = self . mkdtemp ( ) <EOL> expected = self . write_sample_scripts ( source ) <EOL> cmd = self . get_build_scripts_cmd ( target , <EOL> [ os . path . join ( source , fn ) <EOL> for fn in expected ] ) <EOL> cmd . finalize_options ( ) <EOL> cmd . run ( ) <EOL> built = os . listdir ( target ) <EOL> for name in expected : <EOL> self . assertTrue ( name in built ) <EOL> def get_build_scripts_cmd ( self , target , scripts ) : <EOL> import sys <EOL> dist = Distribution ( ) <EOL> dist . scripts = scripts <EOL> dist . command_obj [ "<STR_LIT>" ] = support . DummyCommand ( <EOL> build_scripts = target , <EOL> force = <NUM_LIT:1> , <EOL> executable = sys . executable <EOL> ) <EOL> return build_scripts ( dist ) <EOL> def write_sample_scripts ( self , dir ) : <EOL> expected = [ ] <EOL> expected . append ( "<STR_LIT>" ) <EOL> self . write_script ( dir , "<STR_LIT>" , <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> expected . append ( "<STR_LIT>" ) <EOL> self . write_script ( dir , "<STR_LIT>" , <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> expected . append ( "<STR_LIT>" ) <EOL> self . write_script ( dir , "<STR_LIT>" , <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> return expected <EOL> def write_script ( self , dir , name , text ) : <EOL> f = open ( os . path . join ( dir , name ) , "<STR_LIT:w>" ) <EOL> try : <EOL> f . write ( text ) <EOL> finally : <EOL> f . close ( ) <EOL> def test_version_int ( self ) : <EOL> source = self . mkdtemp ( ) <EOL> target = self . mkdtemp ( ) <EOL> expected = self . write_sample_scripts ( source ) <EOL> cmd = self . get_build_scripts_cmd ( target , <EOL> [ os . path . join ( source , fn ) <EOL> for fn in expected ] ) <EOL> cmd . finalize_options ( ) <EOL> old = sysconfig . get_config_vars ( ) . get ( '<STR_LIT>' ) <EOL> sysconfig . _CONFIG_VARS [ '<STR_LIT>' ] = <NUM_LIT:4> <EOL> try : <EOL> cmd . run ( ) <EOL> finally : <EOL> if old is not None : <EOL> sysconfig . _CONFIG_VARS [ '<STR_LIT>' ] = old <EOL> built = os . listdir ( target ) <EOL> for name in expected : <EOL> self . assertTrue ( name in built ) <EOL> def test_suite ( ) : <EOL> return unittest . makeSuite ( BuildScriptsTestCase ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_unittest ( test_suite ( ) ) </s>
