Morphine and codeine from poppy seeds are sometimes detected in urine tests up to 48 hours after pastries containing poppy seeds are eaten, according to the United States Anti-Doping Agency. Eating poppy seeds usually does not cause a person to test positive on a drug test.
Poppy seeds themselves are digested much like other food is, but are unique in that they contain opium residue. The source states that the amount of opium (and consequently of morphine) residue found on poppy seeds depends on how well they are cleaned, on what country they come from and on the time of harvest. Opium's constituents include morphine and codeine, which is why the USADA recommends that athletes avoid consuming poppy seeds either during or before competitions.