Kids test the adults in their lives, to see how far they can push, to see what limits there truly are. It really isn't about what you tell them you will and won't allow; it is about your day to day interactions with them.
Teachers make classroom rules, send them home in parent letters, post them on their walls, but all that is meaningless to students. Students will test your limits, until they discover how far they can push you.
It is interesting to see students in different settings, different classrooms, to observe how they act/react to the change in expectations. When expectations are high, they tend to rise to meet them. When expectations are lax, they take full advantage of that as well.
The pictures are of my 17 month old granddaughter, Rylie. She is no different that a student in school. She knows just how far she can push me, as well as her mother. She knows that Mom's "no" means a much more solid NO than Grandma's NO. When we are both there, giving her limits, she pushes even farther than she normally would, especially with her mother, just to see if she can get away with the indiscretion.
Kids in school are the same. They play one teacher/adult against the other, trying to seek out the weakest link. They know who to ask the question of, they know who will cave and who will not. Rules they refuse to follow in one classroom, they easily abide by in another.
As adults, we need to keep in mind, students rise to meet our expectations. Set those expectations HIGH and keep them there. Don't ever allow students to give you less than they are capable of.