When buying oil, there is no surefire protection against rancidity. However, good oil can be tested by smell and taste. If this is not possible then there should be confidence that the oil has been stored in a cool, dark place and has not been exposed to temperatures in excess of 22°C for an extended period of time. Oils with a high content of polyphenols (over 250 mg/kg) are also more stable and rarely go rancid. If you accidentally bought rancid oil, this is a reason for an exchange.