Consider two cases.
CASE 1: Without friction
The pulley is totally friction less. Consider segment A. Here, it is acted upon by its weight, upward tension force(T2) exerted by the segment of rope above it and a downward tension force(T1) exerted by the segment below it. Since, it accelerates downwards,
Now, if the rope is mass less, mg=0, also infinitesimal force is required to accelerate that mass less segment, thus ma=0 and T1=T2.
Following the same argument, you can tell downward tension in segment B(T3)=T1=T2. Since, the pulley is friction less, no additional friction force act on segment B and the upward tension force(T4)=T3. In this way, you can tell, tension is same along all the segments of the rope.
CASE 2: With friction
The same argument follows for the segment A as in the previous case. Ultimately, you can show downward tension force in segment B(T3)=T2=T1
But, its different for the upward tension force in the case of segment B.
Here, friction acts in segment B.
ma=tangential component of mg+T3-T4-friction
Since m=0, T3=T4+friction. Hence T3=/=T4. So, in all the segments which are in contact with the pulley, tension aren't equal at both the ends. But as soon as the segment loses contact with the pulley, there you go, tension is equal at both the ends.