When purchasing a used car, are you allowed to bring a mechanic with you to check out under the bonnet or even drive the car to a mechanic for inspection?

How would it work?