Actually I don't. Most often when buying anymore it is via internet. Not feasible. I protect myself by buying from name suppliers with a good record of service after the sale, like Patricks Trains.
When buying used at a swap meet I look it over for wires sticking out, signs of modification or repairs, missing parts, etc., and try to see if it runs. When buying used over the internet (rare anymore) I ask for a good price and assume I am buying a problem child.
When buying new, sealed in the box, at an LHS or swap meet or internet, experience indicates inspection/test run is not particularly useful. All of the serious problems I have had with new locos (those I could not or decided would not try to fix), did not occur right out of the box but within a half hour to two hours. I have had several serious problems over the years - four come to mind. All of them occurred more than five to ten minutes into running the new loco, so all would have passed any inspection and brief test in the store, etc. Anything I have ever found wrong right out of the box - part broken, fallen off - could be fixed easily, so . . I just don't pre-purchase inspect new locos.