def test_set(self):
        name = 'pager'
        path = '/usr/bin/less'

        ret = {'name': name,
               'path': path,
               'result': True,
               'changes': {},
               'comment': ''}

        mock = MagicMock(side_effect=[path, path, ''])
        mock_bool = MagicMock(return_value=True)
        mock_bol = MagicMock(side_effect=[path, False, False, False, False])
        with patch.dict(alternatives.__salt__,
                        {'alternatives.display': mock,
                         'alternatives.show_current': mock_bol,
                         'alternatives.set': mock_bool}):
            comt = ('Alternative for {0} already set to {1}'.format(name, path))
            ret.update({'comment': comt})
            self.assertDictEqual(alternatives.set_(name, path), ret)

            comt = ('Alternative for {0} will be set to path False'
                    ).format(name)
            ret.update({'comment': comt, 'result': None})
            with patch.dict(alternatives.__opts__, {'test': True}):
                self.assertDictEqual(alternatives.set_(name, path), ret)

            comt = 'Alternative for {0} not updated'.format(name)
            ret.update({'comment': comt, 'result': True})
            with patch.dict(alternatives.__opts__, {'test': False}):
                self.assertDictEqual(alternatives.set_(name, path), ret)

            comt = ('Alternative {0} for {1} doesn\'t exist').format(path, name)
            ret.update({'comment': comt, 'result': False})
            self.assertDictEqual(alternatives.set_(name, path), ret)
Register a file object.
dataset/ETHPy150Open saltstack/salt/tests/unit/states/alternatives_test.py/AlternativesTestCase.test_set--crossover with--dataset/ETHPy150Open dpkp/kafka-python/kafka/selectors34.py/BaseSelector.register