Suppose $f(z)$ is analytic in the open region $D$, and $C$ is a simple closed curve in $D$. For any $z_0\in D\setminus C$, prove: $$\oint_C\frac{f'(z)}{z-z_0}\mathrm{d}z=\oint_C\frac{f(z)}{(z-z_0)^2}\mathrm{d}z.$$
It is a homework problem immediately after the introduction of complex integral and Cauchy's integral theorem.
When the region $S$ surrounded by $C$ is contained in $D$, the value of the above integral is either both $2\pi i f'(z_0)$ (when $z_0\in S$) or both $0$ (when $z_0\notin S$). But in the case when $S\not\subset D$, which means $C$ encircles some holes or singular point of $D$, I don't know how to handle it.
Any idea or hint will be appreciated, thank you!
If you don't see the answer directly (and I admit that I had to think about it too), the crucial point that leads you to a solution is that the equality is asserted for an arbitrary simple closed curve. The "simple" part is not important, since any closed curve is up to homotopy decomposable into finitely many simple closed curves, so we see that the equality must hold for any closed curve.
But if $g$ and $h$ are functions such that
$$\int_C g(z)\,dz = \int_C h(z)\,dz$$
for all closed curves $C$ in $D\setminus \{z_0\}$, then for $k = g-h$ that reads
$$\int_C k(z)\,dz = 0$$
for all closed curves in $D\setminus \{z_0\}$.
And that we recognise as the condition for $k$ to have a primitive on $D\setminus \{z_0\}$, for it says that, with an arbitrarily chosen $z_1$
$$K(z) = \int_{z_1}^z k(\zeta)\,d\zeta$$
is independent of the chosen path connecting $z_1$ and $z$, hence a well-defined function on $D\setminus \{z_0\}$. [I assume $D$ is connected, otherwise apply the same reasoning to each connected component; the use of the term "region" to denote any open set or a connected open set is not universally agreed upon.]
Thus, we are led to the conclusion that
$$\frac{f'(z)}{z-z_0} - \frac{f(z)}{(z-z_0)^2}$$
must be the derivative of a holomorphic function on $D\setminus \{z_0\}$.
Once you know what you are looking for, it is easily seen that
$$\frac{d}{dz}\frac{f(z)}{z-z_0} = \frac{f'(z)}{z-z_0} - \frac{f(z)}{(z-z_0)^2}$$
and hence the asserted equality
$$\int_C \frac{f'(z)}{z-z_0}\,dz = \int_C \frac{f(z)}{(z-z_0)^2}\,dz$$
follows.