<s> """<STR_LIT>""" <EOL> import os <EOL> from bzt . engine import ScenarioExecutor <EOL> from bzt . utils import BetterDict , EXE_SUFFIX , is_windows <EOL> from tests import BZTestCase , __dir__ , local_paths_config <EOL> from tests . mocks import EngineEmul <EOL> class TestEngine ( BZTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestEngine , self ) . setUp ( ) <EOL> self . obj = EngineEmul ( ) <EOL> self . paths = local_paths_config ( ) <EOL> def test_requests ( self ) : <EOL> configs = [ <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> self . paths <EOL> ] <EOL> self . obj . configure ( configs ) <EOL> self . obj . prepare ( ) <EOL> for executor in self . obj . provisioning . executors : <EOL> executor . _env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . obj . run ( ) <EOL> self . obj . post_process ( ) <EOL> def test_double_exec ( self ) : <EOL> configs = [ <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> self . paths <EOL> ] <EOL> self . obj . configure ( configs ) <EOL> self . obj . prepare ( ) <EOL> for executor in self . obj . provisioning . executors : <EOL> executor . _env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . obj . run ( ) <EOL> self . obj . post_process ( ) <EOL> def test_unknown_module ( self ) : <EOL> configs = [ <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> __dir__ ( ) + "<STR_LIT>" , <EOL> self . paths <EOL> ] <EOL> self . obj . configure ( configs ) <EOL> self . obj . config [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> self . obj . config [ "<STR_LIT>" ] [ "<STR_LIT>" ] = BetterDict ( ) <EOL> try : <EOL> self . obj . prepare ( ) <EOL> self . fail ( ) <EOL> except ValueError : <EOL> pass <EOL> class TestScenarioExecutor ( BZTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestScenarioExecutor , self ) . setUp ( ) <EOL> self . engine = EngineEmul ( ) <EOL> self . executor = ScenarioExecutor ( ) <EOL> self . executor . engine = self . engine <EOL> def test_creates_hostaliases_file ( self ) : <EOL> self . engine . config . merge ( { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> } <EOL> } ) <EOL> path = os . path . join ( __dir__ ( ) , "<STR_LIT:data>" , "<STR_LIT>" + EXE_SUFFIX ) <EOL> process = self . executor . execute ( [ path ] ) <EOL> stdout , _ = process . communicate ( ) <EOL> hosts_file = os . path . join ( self . engine . artifacts_dir , "<STR_LIT>" ) <EOL> self . assertTrue ( os . path . exists ( hosts_file ) ) <EOL> self . assertIn ( hosts_file , str ( stdout ) ) <EOL> def test_doesnt_create_hostaliases ( self ) : <EOL> self . executor . execute ( [ "<STR_LIT>" ] ) <EOL> hosts_file = os . path . join ( self . engine . artifacts_dir , "<STR_LIT>" ) <EOL> self . assertFalse ( os . path . exists ( hosts_file ) ) <EOL> def test_passes_artifacts_dir ( self ) : <EOL> cmdline = "<STR_LIT>" if is_windows ( ) else "<STR_LIT>" <EOL> process = self . executor . execute ( cmdline , shell = True ) <EOL> stdout , _ = process . communicate ( ) <EOL> self . assertEquals ( self . engine . artifacts_dir , stdout . decode ( ) . strip ( ) ) </s>
