However, if your traffic stop is for a moving offense that warrants arrest (DUI, for instance, or reckless driving), all bets are off, because the police can do intrusive searches incident to an arrest.
Also, if you're stopped for a moving violation and either authorize a search, or have evidence of probable cause in plain view (for instance, a bag of weed in the passenger seat), all bets are again off.