<s> import test . test_support , unittest <EOL> import sys <EOL> import popen2 <EOL> import subprocess <EOL> class CmdLineTest ( unittest . TestCase ) : <EOL> def start_python ( self , cmd_line ) : <EOL> outfp , infp = popen2 . popen4 ( '<STR_LIT>' % ( sys . executable , cmd_line ) ) <EOL> infp . close ( ) <EOL> data = outfp . read ( ) <EOL> outfp . close ( ) <EOL> return data <EOL> def exit_code ( self , cmd_line ) : <EOL> return subprocess . call ( [ sys . executable , cmd_line ] , stderr = subprocess . PIPE ) <EOL> def test_directories ( self ) : <EOL> self . assertNotEqual ( self . exit_code ( '<STR_LIT:.>' ) , <NUM_LIT:0> ) <EOL> self . assertNotEqual ( self . exit_code ( '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> def verify_valid_flag ( self , cmd_line ) : <EOL> data = self . start_python ( cmd_line ) <EOL> self . assertTrue ( data == '<STR_LIT>' or data . endswith ( '<STR_LIT:\n>' ) , repr ( data ) ) <EOL> self . assertTrue ( '<STR_LIT>' not in data ) <EOL> def test_environment ( self ) : <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> def test_optimize ( self ) : <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> def test_q ( self ) : <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> def test_site_flag ( self ) : <EOL> self . verify_valid_flag ( '<STR_LIT>' ) <EOL> def test_usage ( self ) : <EOL> self . assertTrue ( '<STR_LIT>' in self . start_python ( '<STR_LIT>' ) ) <EOL> def test_version ( self ) : <EOL> version = '<STR_LIT>' % sys . version_info [ : <NUM_LIT:2> ] <EOL> self . assertTrue ( self . start_python ( '<STR_LIT>' ) . startswith ( version ) ) <EOL> def test_main ( ) : <EOL> test . test_support . run_unittest ( CmdLineTest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
