Use unittest.mock if available.