<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import unittest <EOL> class LauncherTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def run_test ( self , script , args ) : <EOL> """<STR_LIT>""" <EOL> old_cwd = os . getcwd ( ) <EOL> test_dir = os . path . dirname ( os . path . dirname ( __file__ ) ) <EOL> cmd = '<STR_LIT>' % ( sys . executable , script ) <EOL> cmd += '<STR_LIT>' . join ( [ '<STR_LIT>' % arg for arg in args ] ) <EOL> os . chdir ( test_dir ) <EOL> try : <EOL> from subprocess import Popen , PIPE <EOL> p = Popen ( cmd , shell = True , stdin = PIPE , stdout = PIPE , stderr = PIPE ) <EOL> stdin , stdout , stderr = ( p . stdin , p . stdout , p . stderr ) <EOL> except ImportError : <EOL> stdin , stdout , stderr = os . popen3 ( cmd ) <EOL> out , err = stdout . read ( ) , stderr . read ( ) <EOL> os . chdir ( old_cwd ) <EOL> return out , err <EOL> def run_startfms ( self , args ) : <EOL> return self . run_test ( '<STR_LIT>' , args ) <EOL> def assert_output ( self , stream , msg ) : <EOL> """<STR_LIT>""" <EOL> self . failUnless ( msg in stream , <EOL> "<STR_LIT>" % ( msg , stream ) ) <EOL> def assert_no_output ( self , stream ) : <EOL> """<STR_LIT>""" <EOL> self . assertEquals ( len ( stream ) , <NUM_LIT:0> , <EOL> "<STR_LIT>" % stream ) <EOL> def test_missing_command_name ( self ) : <EOL> """<STR_LIT>""" <EOL> out , err = self . run_startfms ( [ ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> self . assert_output ( out , <EOL> '<STR_LIT>' ) <EOL> def test_unknown_command_name ( self ) : <EOL> """<STR_LIT>""" <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' ] ) <EOL> self . assert_no_output ( out ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_no_experiment_file_name ( self ) : <EOL> """<STR_LIT>""" <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' ] ) <EOL> self . assert_no_output ( out ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_bad_option ( self ) : <EOL> """<STR_LIT>""" <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_version_option ( self ) : <EOL> """<STR_LIT>""" <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' ] ) <EOL> self . assert_output ( out , <EOL> '<STR_LIT>' ) <EOL> def test_verbose_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ option , '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_showbooks_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ option , '<STR_LIT>' , configfile ] ) <EOL> self . assert_no_output ( out ) <EOL> out , err = self . run_startfms ( [ option , '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( out , <EOL> '<STR_LIT>' ) <EOL> def test_replay_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , option , '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_timer_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ option , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , "<STR_LIT>" ) <EOL> def test_unique_by_agent ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> configfile ] ) <EOL> self . assert_output ( err , "<STR_LIT>" ) <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> configfile ] ) <EOL> self . assert_output ( err , "<STR_LIT>" ) <EOL> def test_loglevel_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ option , '<STR_LIT>' , '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , <EOL> '<STR_LIT>' ) <EOL> def test_orderslogfilename_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> def test_outputfilename_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , option , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> def test_randomseed_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> def test_csvdelimiter_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> def test_repeat_option ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> def test_repeat_option_outfiles ( self ) : <EOL> """<STR_LIT>""" <EOL> configfile = '<STR_LIT>' <EOL> out , err = self . run_startfms ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , configfile ] ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> self . assert_output ( err , '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
