@patch('os.listdir', MagicMock(return_value=['']))
    def test_remove(self):
        mock = MagicMock(return_value='')
        with patch.dict(cpan.__salt__, {'cmd.run': mock}):
            mock = MagicMock(return_value={'installed version': '2.1',
                                           'cpan build dirs': [''],
                                           'installed file': '/root'})
            with patch.object(cpan, 'show', mock):
                self.assertDictEqual(cpan.remove('Alloy'),
                                     {'new': None, 'old': '2.1'})
Test if it remove a module using cpan
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/cpan_test.py/CpanTestCase.test_remove