Do not set a trap for your child. What does this mean? Do not forbid him to do something which you know from the outset he cannot withstand, and then punish him for it. And even if you do not punish him, it will create within him a guilty conscience and unpleasant feelings that he was not able to meet the expectations. Even our Sages did not enact decrees which the community could not properly observe. And even Hashem did not command us in His Torah to do anything beyond our capacity. And He does not send anyone a trial if he does not have the capacity to withstand it. Everything is thus dependent on a person's free choice.
But a young child possesses a limited amount of free choice. He should therefore not be tested. It is true that a test builds a person's character but a person experiences enough natural tests from the world around him, and he doesn't always withstand those.
A parent's role is then to comfort him and help him digest his failure in order to transmit to him: My dear child, failures occur in life, but regardless, I love you.