def test_unlink_ENOENT(self): self.mox.StubOutWithMock(os, "unlink") os.unlink("/fake/path").AndRaise(OSError(errno.ENOENT)) self.mox.ReplayAll() utils.unlink_without_raise("/fake/path") self.mox.UnsetStubs() self.mox.VerifyAll()
def test_unlink(self): self.mox.StubOutWithMock(os, "unlink") os.unlink("/fake/path") self.mox.ReplayAll() utils.unlink_without_raise("/fake/path") self.mox.UnsetStubs() self.mox.VerifyAll()
def test_unlink_ENOENT(self): with mock.patch.object(os, "unlink") as unlink_mock: unlink_mock.side_effect = OSError(errno.ENOENT) utils.unlink_without_raise("/fake/path") unlink_mock.assert_called_once_with("/fake/path")
def test_unlink(self): with mock.patch.object(os, "unlink") as unlink_mock: unlink_mock.return_value = None utils.unlink_without_raise("/fake/path") unlink_mock.assert_called_once_with("/fake/path")