#NEWLINE# def test_portage_detect( ) : #NEWLINE# #INDENT# if ( not is_gentoo ( ) ) : #NEWLINE# #INDENT# print ( 'Skipping not Gentoo' ) #NEWLINE# return #NEWLINE# #UNINDENT# from rosdep2.platforms.gentoo import portage_detect #NEWLINE# m = Mock ( ) #NEWLINE# m . return_value = [ ] #NEWLINE# val = portage_detect ( [ ] , exec_fn = m ) #NEWLINE# assert ( val == [ ] ) , val #NEWLINE# m = Mock ( return_value = [ ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' ] , exec_fn = m ) #NEWLINE# assert ( val == [ ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_called_with ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m = Mock ( return_value = [ 'dev-libs/tinyxml-2.6.2-r1' ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' ] , exec_fn = val ) #NEWLINE# assert ( val == [ 'tinyxml[stl]' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_called_with ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m = Mock ( side_effect = [ [ 'sys-devel/gcc-4.5.3-r2' ] , [ 'dev-libs/tinyxml-2.6.2-r1' ] ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' , 'gcc' ] , exec_fn = m ) #NEWLINE# assert ( val == [ 'gcc' , 'tinyxml[stl]' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'gcc' ] ) #NEWLINE# m = Mock ( side_effect = [ [ ] , [ ] ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' , 'gcc' ] , exec_fn = m ) #NEWLINE# assert ( val == [ ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'gcc' ] ) #NEWLINE# m = Mock ( side_effect = [ [ 'sys-devel/gcc-4.5.3-r2' ] , [ ] ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' , 'gcc' ] , exec_fn = m ) #NEWLINE# assert ( val == [ 'gcc' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'gcc' ] ) #NEWLINE# m = Mock ( side_effect = [ [ ] , [ 'dev-libs/tinyxml-2.6.2-r1' ] ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' , 'gcc' ] , exec_fn = m ) #NEWLINE# assert ( val == [ 'tinyxml[stl]' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'gcc' ] ) #NEWLINE# m = Mock ( side_effect = [ [ 'dev-libs/tinyxml-2.6.2-r1' ] , [ 'dev-libs/tinyxml-2.6.2-r1' ] ] ) #NEWLINE# val = portage_detect ( [ 'tinyxml[stl]' , 'tinyxml[stl]' ] , exec_fn = m ) #NEWLINE# assert ( val == [ 'tinyxml[stl]' , 'tinyxml[stl]' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'tinyxml[stl]' ] ) #NEWLINE# m = Mock ( side_effect = [ [ 'dev-lang/python-2.7.2-r3' , 'dev-lang/python-3.2.2' ] ] ) #NEWLINE# val = portage_detect ( [ 'python' ] , exec_fn = m ) #NEWLINE# assert ( val == [ 'python' ] ) , ( 'Result was actually: %s' % val ) #NEWLINE# m . assert_any_call ( [ 'portageq' , 'match' , '/' , 'python' ] )