Many courts require a person out on bond to take regular urinalysis teste in order to enuse they are not taking any illegal substances. It is called a condition of their bond. A positive UA could, and most likwly will, case the bond to be found insufficient, the person to be arrested in court and required to post a new bond. It is the probation department that oversees the UA's. If the judge askes if you might test positive, be homest and tell him what might show up. Usually you get a "pass" in a first test if you are honest. However, if you show up to court under the influence, that ia a whole other story.
You should be prepared to submit to a drug test at any court hearing. I would say they are less likely during a normal pretrial setting as opposed to a meeting with a P.O. but depending on the jurisiction and judge anything can happen. The safest bet is to stay clean at least as long as the case is ongoing.
White & Measells LLP
1205 Rio Grande Street
Austin, TX 78701