<s> """<STR_LIT>""" <EOL> import StringIO <EOL> import unittest <EOL> import mock <EOL> import pytest <EOL> import qisys . error <EOL> import qibuild . actions . open <EOL> class OpenTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . ask_patcher = mock . patch ( '<STR_LIT>' ) <EOL> self . ask_mock = self . ask_patcher . start ( ) <EOL> def test_no_ide_in_conf ( self ) : <EOL> empty_cfg = qibuild . config . QiBuildConfig ( ) <EOL> self . assertEqual ( qibuild . actions . open . get_ide ( empty_cfg ) , None ) <EOL> def test_qt_creator_in_conf ( self ) : <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> qt_creator = qibuild . config . IDE ( ) <EOL> qt_creator . name = "<STR_LIT>" <EOL> qt_creator . path = "<STR_LIT>" <EOL> qibuild_cfg . add_ide ( qt_creator ) <EOL> ide = qibuild . actions . open . get_ide ( qibuild_cfg ) <EOL> self . assertEqual ( ide . name , "<STR_LIT>" ) <EOL> self . assertEqual ( ide . path , "<STR_LIT>" ) <EOL> self . assertFalse ( self . ask_mock . called ) <EOL> def test_two_ides ( self ) : <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> vs = qibuild . config . IDE ( ) <EOL> vs . name = "<STR_LIT>" <EOL> qt_creator = qibuild . config . IDE ( ) <EOL> qt_creator . name = "<STR_LIT>" <EOL> qt_creator . path = r"<STR_LIT>" <EOL> qibuild_cfg . add_ide ( qt_creator ) <EOL> qibuild_cfg . add_ide ( vs ) <EOL> self . ask_mock . return_value = "<STR_LIT>" <EOL> ide = qibuild . actions . open . get_ide ( qibuild_cfg ) <EOL> self . assertEqual ( ide . name , "<STR_LIT>" ) <EOL> self . assertEqual ( ide . path , r"<STR_LIT>" ) <EOL> call_args_list = self . ask_mock . call_args_list <EOL> self . assertEqual ( len ( call_args_list ) , <NUM_LIT:1> ) <EOL> ( choices , _question ) = call_args_list [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( choices , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def test_two_ides_matching_default_conf ( self ) : <EOL> global_cfg = StringIO . StringIO ( r"""<STR_LIT>""" ) <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> qibuild_cfg . read ( global_cfg , create_if_missing = False ) <EOL> local_cfg = StringIO . StringIO ( r"""<STR_LIT>""" ) <EOL> qibuild_cfg . read_local_config ( local_cfg ) <EOL> ide = qibuild . actions . open . get_ide ( qibuild_cfg ) <EOL> self . assertEqual ( ide . name , "<STR_LIT>" ) <EOL> self . assertEqual ( ide . path , r"<STR_LIT>" ) <EOL> def test_two_ides_matching_user_conf ( self ) : <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> global_cfg = StringIO . StringIO ( r"""<STR_LIT>""" ) <EOL> qibuild_cfg . read ( global_cfg , create_if_missing = False ) <EOL> qibuild_cfg . set_active_config ( "<STR_LIT>" ) <EOL> ide = qibuild . actions . open . get_ide ( qibuild_cfg ) <EOL> self . assertEqual ( ide . name , "<STR_LIT>" ) <EOL> self . assertFalse ( self . ask_mock . called ) <EOL> def tearDown ( self ) : <EOL> self . ask_patcher . stop ( ) <EOL> def test_eclipse_cdt_in_conf ( record_messages ) : <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> eclipse = qibuild . config . IDE ( ) <EOL> eclipse . name = "<STR_LIT>" <EOL> qibuild_cfg . add_ide ( eclipse ) <EOL> with pytest . raises ( SystemExit ) as e : <EOL> qibuild . actions . open . get_ide ( qibuild_cfg ) <EOL> assert e . value . code != <NUM_LIT:0> <EOL> assert not record_messages . find ( "<STR_LIT>" ) <EOL> assert record_messages . find ( "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
