A number of years ago when I was in med school there was an old professor of OBGYN who argued rather persuasively that it was unethical for patients to refuse to be treated by a student/trainee/whatever. (for context where I went to med school mainly treated a wealthy population). He argued that back in the old days the main teaching hospitals were all state/county hospitals for the indigent, and if we're only having the most needy patients treated by inexperienced clinicians, then we're not giving equal care to patients across the socioeconomic spectrum. The bleeding heart liberal in me agreed.
...However...
I'm a VERY firm believer that a patient's autonomy to make medical decisions is not to be violated wherever possible, and for patients to have that autonomy they need to be fully informed about both what is being done and who is doing it. If a patient doesn't want a trainee involved in their care, that's their right, even if I don't agree with their decision. Hell, sometimes patient take that to stupid levels...insisting that the attending neurologist perform your lumbar puncture when the attending probably hasn't done one in two years for example... but if the patient is informed that the attending is likely not fresh whereas the senior residents do them daily, and it may involve you having to come back when he/she has the free time to do it, and the risks of waiting for the procedure to be done, etc, well that's their call if they want to be a stubborn ass about their care. Perhaps they should have known better than to come to a teaching hospital, but whatever. Being ambiguous or less than fully honest about roles for the sake of expediency gets the job done, but it violates a patient's autonomy.
The people who know my identity on this site (hi guys!) know I've had many a discussion about this topic, and a lot of it comes from being asked to do things as a 3rd and 4th year medical student that I simply didn't think were right. Said people know this left a bad taste in my mouth early on when I stood up for myself about the topic. (can you tell I didn't honor much as a clinical years student?). We all want students to get the skills necessary to ultimately become experienced physicians, but that comes in time either way. The patients you experience as a student are there with their own real medical problems and with their own sets of expectations about their care and those have to (if well-informed) be respected. For every patient telling you to GTFO as a student, there will be 4 or more who are more than happy that they're educating future physicians.