<s> from __future__ import absolute_import <EOL> import os <EOL> from salttesting import skipIf <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import NO_MOCK , NO_MOCK_REASON , patch <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> import integration <EOL> import salt . utils <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class TestWhich ( integration . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> @ patch ( '<STR_LIT>' , lambda exe : None ) <EOL> def test_missing_binary_in_linux ( self ) : <EOL> self . assertTrue ( <EOL> salt . utils . which ( '<STR_LIT>' ) is None <EOL> ) <EOL> @ patch ( '<STR_LIT>' , lambda exe : exe ) <EOL> def test_existing_binary_in_linux ( self ) : <EOL> self . assertTrue ( salt . utils . which ( '<STR_LIT>' ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_existing_binary_in_windows ( self , osaccess ) : <EOL> osaccess . side_effect = [ <EOL> False , <EOL> False , <EOL> True <EOL> ] <EOL> with patch . dict ( os . environ , { '<STR_LIT>' : '<STR_LIT>' } ) : <EOL> with patch ( '<STR_LIT>' , lambda : True ) : <EOL> with patch ( '<STR_LIT>' , lambda x : True ) : <EOL> self . assertEqual ( <EOL> salt . utils . which ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_missing_binary_in_windows ( self , osaccess ) : <EOL> osaccess . side_effect = [ <EOL> False , <EOL> False , False , False , False , False <EOL> ] <EOL> with patch . dict ( os . environ , { '<STR_LIT>' : '<STR_LIT>' } ) : <EOL> with patch ( '<STR_LIT>' , lambda : True ) : <EOL> self . assertEqual ( <EOL> salt . utils . which ( '<STR_LIT>' ) , <EOL> None <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_existing_binary_in_windows_pathext ( self , osaccess ) : <EOL> osaccess . side_effect = [ <EOL> False , <EOL> False , <EOL> False , False , False , <EOL> True <EOL> ] <EOL> with patch . dict ( os . environ , { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> '<STR_LIT>' } ) : <EOL> with patch ( '<STR_LIT>' , lambda : True ) : <EOL> with patch ( '<STR_LIT>' , lambda x : True ) : <EOL> self . assertEqual ( <EOL> salt . utils . which ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( TestWhich , needs_daemon = False ) </s>
