The best bet is to be 100% up front with your sport's sanctioning body or if it's just an independent event, with the people running the event. If you show that you have a doctor's prescription and it's to treat an actual condition/illness, your sport may be able to issue you an exception. If you try to go out of your way to conceal your TRT usage, you'll less likely to get an exception if you're caught.
But as far as your question to evade a drug test goes. It depends a lot on the types of drug tests your sport does. With oral steroids like 5-6 weeks should be enough (the actual times depend on your body and the specific steroids). Things like Deca can be tested for over a year I believe and the other synthetic steroids are relatively easy for them to test (if within their normal detection times)
Now if all you're taking is testosterone, they may test for how much is in your system. They can also test for abnormalities in your SHBG, your FSH and LH levels. Another thing they may test for is the ratio between your testosterone and epitestosterone levels. And they can test the carbon isotope ratio in the testosterone you have in your system.
You can google "detection times"for just about ever steroid and ever ester to see how long it'll take to clear your system. But really, the best bet is to be upfront and honest.