It will depend upon the teacher/school rules. I teach Junior High language, and let me share our rules.
In writing an informal essay, using idioms can "color" the essay and make it more interesting, and I my students at school to use a couple but not very many. In a formal essay, an idiom may be used in quoting someone or when specifically trying to prove a point.
Poems can be tricky. If a short poem is being used at the end to "tie" the essay together with one more example, it may be printed out. A longer poem (3 stanzas or more) is unacceptable, but the title may be referred to in italics. I hope this helps.