<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import os <EOL> import platform <EOL> from salttesting import TestCase , skipIf <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import ( <EOL> MagicMock , <EOL> patch , <EOL> NO_MOCK , <EOL> NO_MOCK_REASON <EOL> ) <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> import salt . utils <EOL> from salt . grains import core <EOL> core . __salt__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class CoreGrainsTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> @ skipIf ( not salt . utils . is_linux ( ) , '<STR_LIT>' ) <EOL> def test_gnu_slash_linux_in_os_name ( self ) : <EOL> '''<STR_LIT>''' <EOL> _path_exists_map = { <EOL> '<STR_LIT>' : False <EOL> } <EOL> _path_isfile_map = { } <EOL> _cmd_run_map = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> path_exists_mock = MagicMock ( side_effect = lambda x : _path_exists_map [ x ] ) <EOL> path_isfile_mock = MagicMock ( <EOL> side_effect = lambda x : _path_isfile_map . get ( x , False ) <EOL> ) <EOL> cmd_run_mock = MagicMock ( <EOL> side_effect = lambda x : _cmd_run_map [ x ] <EOL> ) <EOL> empty_mock = MagicMock ( return_value = { } ) <EOL> orig_import = __import__ <EOL> def _import_mock ( name , * args ) : <EOL> if name == '<STR_LIT>' : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> return orig_import ( name , * args ) <EOL> with patch . object ( salt . utils , '<STR_LIT>' , <EOL> MagicMock ( return_value = False ) ) : <EOL> with patch . object ( core , '<STR_LIT>' , <EOL> MagicMock ( return_value = False ) ) : <EOL> with patch . object ( os . path , '<STR_LIT>' , path_exists_mock ) : <EOL> with patch ( '<STR_LIT>' , <EOL> side_effect = _import_mock ) : <EOL> with patch . object ( os . path , '<STR_LIT>' , path_isfile_mock ) : <EOL> distro_mock = MagicMock ( <EOL> return_value = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) <EOL> with patch . object ( <EOL> platform , <EOL> '<STR_LIT>' , <EOL> distro_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . object ( <EOL> core , <EOL> '<STR_LIT>' , <EOL> empty_mock ) : <EOL> with patch . dict ( <EOL> core . __salt__ , <EOL> { '<STR_LIT>' : cmd_run_mock } ) : <EOL> os_grains = core . os_data ( ) <EOL> self . assertEqual ( os_grains . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( CoreGrainsTestCase , needs_daemon = False ) </s>
