The Gemara in Maseches Yoma (35b) goes into great detail of how difficult it was for Yosef HaTzaddik to fight his yetzer hara and how he succeeded.
The Gemara discusses how wicked people are still expected to learn Torah, and when their life in olam hazeh is over and they’re judged by how much Torah they learned, they can’t use as an excuse that they were too busy fighting their yetzer hara due to their being handsome, because Yosef HaTzaddik had to fight it more for the same reason and he still found time to learn.
They said about Yosef HaTzaddik: Each and every day the wife of Potiphar would attempt to seduce him with words. Clothes she wore for him in the morning she would not wear for him in the evening; clothes she wore for him in the evening she would not war for him in the morning. Potiphar's wife said to Yosef, “Surrender yourself to me.” He answered her, “No.” She threatened him, “I shall confine you in prison.” He answered her, “Hashem releases the imprisoned.” She said to him, “I shall bend your proud stature.” He replied, “Hashem straightens the bent.” She threatened, “I will blind your eyes.” He replied, “Hashem gives sight to the blind.” She gave him one thousand silver bars so that he would listen to her to lie beside her, to be with her, but he did not want to listen to her. He didn't lie with her in this world because he didn't want to be with her in the World to Come.
Joseph Accused by Potiphar's Wife,
by Rembrandt van Rijn, 1655.
See this excerpt from Women's Rights in Old Testament Times by James R. Baker, Signature Books; Slat Lake City 1992:
"Even with our limited understanding of Egyptian law, this seems like light punishment for attempted rape of the wife of a high-ranking official of the Egyptian government. An instructive Egyptian folk tale from the thirteenth century B.C., about two or three hundred years after Joseph's period, concerns two brothers, Anubis and Bata. Anubis was married, and Bata came to work for him on his farm. One day as they were out planting in the field, Anubis sent Bata to the house to get more seed. Not wishing to make more than one trip, Bata took a huge load. Anubis's wife admired his physical strength and suggested he spend an hour in bed with her. Appalled, Bata told her never to say such a thing again and he would not mention anything about it.
The unnamed angry wife ingested some fat and grease to make herself sick and to look as if she had been beaten. When her husband came home, she told him that Bata had propositioned her and that when she had refused he had beaten her so she would not tell. She asked him to kill Bata so that he would not try to rape her again. Anubis was enraged and waited in ambush at the shed for Bata. As Bata brought the cows into the shed, the animals warned him of Anubis's intent, and Bata was able to escape.
After a long chase Bata and Anubis talked at a distance. Bata convinced Anubis of his innocence, and Anubis after returning home slew his wife and threw her body to the dogs.5 If this story embodies any accepted Egyptian legal principle, death may have been the penalty for attempted rape.6 Perhaps Potiphar was less than convinced by his wife's evidence. In the biblical story, Joseph eventually rises to become chief minister of Egypt, but the wife of Potiphar is not heard from again."