def test_make_symlinks_link_exists(self): with mock.patch('os.symlink'), mock.patch('os.path.islink'), \ mock.patch('os.remove') as mock_remove: this = os.path.abspath(__file__) make_simlinks(os.path.dirname(this), [this]) arg = mock_remove.call_args[0][0] self.assertEqual(arg, this)
def test_make_symlinks(self): with mock.patch('os.symlink') as mock_symlink: make_simlinks('/my/dest', ['/from/source_1', '/from/source_2']) calls = mock_symlink.call_args_list self.assertEqual(len(calls), 2) self.assertEqual(calls[0][0][1], '/my/dest/source_1') self.assertEqual(calls[1][0][1], '/my/dest/source_2')
def test_make_symlink_path_exists(self): with mock.patch('os.symlink') as mock_symlink: this = os.path.abspath(__file__) make_simlinks(os.path.dirname(this), [this]) self.assertEqual(0, mock_symlink.call_count)