#NEWLINE# def test_install_pre_argument_in_resulting_command( self ) : #NEWLINE# #INDENT# pkg = 'pep8' #NEWLINE# mock = MagicMock ( side_effect = [ { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : 'pip 1.2.0 /path/to/site-packages/pip' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : '' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# with patch . dict ( pip . __salt__ , { #NEWLINE# #INDENT# 'cmd.run_all' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch ( 'salt.modules.pip.version' , MagicMock ( return_value = '1.3' ) ) : #NEWLINE# #INDENT# pip . install ( self , pre_releases = True ) #NEWLINE# mock . assert_called_with ( [ 'pip' , 'install' , pkg ] , saltenv = 'base' , runas = None , use_vt = False , python_shell = False ) #NEWLINE# #UNINDENT# #UNINDENT# mock_run = MagicMock ( return_value = 'pip 1.4.1 /path/to/site-packages/pip' ) #NEWLINE# mock_run_all = MagicMock ( return_value = { #NEWLINE# #INDENT# 'retcode' : 0 , #NEWLINE# 'stdout' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pip . __salt__ , { #NEWLINE# #INDENT# 'cmd.run' : mock_run , #NEWLINE# 'cmd.run_all' : mock_run_all , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch ( 'salt.modules.pip._get_pip_bin' , MagicMock ( return_value = 'pip' ) ) : #NEWLINE# #INDENT# pip . install ( pkg , pre_releases = True ) #NEWLINE# mock_run_all . assert_called_with ( [ 'pip' , 'install' , '--pre' , pkg ] , saltenv = 'base' , runas = None , use_vt = False , python_shell = False )