# Heat capacity at constant volume and internal energy

I read that heat supplied at constant volume to a system containing ideal gas changes the internal energy of system, i.e $q=nC_v\Delta T=\delta U$

But what happens if I heat a system and change its temperature from $T_1$ to $T_2$ with system not being at constant volume, can I still say that $\delta U=nC_v\Delta T$? Is there any proof regarding this?

Yes, you can apply the formula $\Delta U$=nCv$\Delta T$ for an ideal gas in a container whether or not the process is isochoric.
This is because the change in internal energy for an ideal gas undergoing some mechanical process is mainly affected by the change in kinetic energy of the gas. It does not depend on the change in volume of gas.So as long as the temperature difference is same the change in internal energy will be same. Heat capacity is the amount of heat required to raise the temperature of a substance by 1 unit so $\Delta U$ is directly proportional to heat capacity and $\Delta T$ along with the number of moles of gas.
When the process is carried with constant volume only then $\Delta W$ is $0$ so in that case $\Delta Q$=$\Delta U$ whereas $\Delta U$=nCv$\Delta T$ holds good always for an ideal gas under some mechanical process.