What qualifications or training allow a test pilot to fly a new aircraft?
All commercial or military test pilots attend either a DoD or ABET approved test pilot school.  The military has two said achools: the USAFTPS at Edwards AFB in Muroc, CA and the USNTPS out at NAS Pax River in MD.  There are at least two test pilot schools who train civilian pilots that I know of: The National Test Pilots School in Muroc, CA and Empire Test Pilot School in the UK.

Qualified applicants need to possess at least a commercial pilot's certificate and at least 750 hours TT, plus possess at least a bachelor's degree in engineering, physics, or related technical discipline.  Military programs are very competitive and sought after; TPS slots can pretty much guarantee a job with major aircraft OEMs doing test pilot work after their military service ends.  Outside of the military you will probably need some kind of corporate sponsorship to attend as it is very expensive. The NTPS Masters of Science in Test piloting in an 11-month course costing a whopping $960,000 to attend!

The courses in a TPS are graduate level type classes.  The NTPS curriculum can be found here.

Hollywood portrays test pilots as these outlandish, devil-may-care guys with brass balls and ice water running in their veins, but the truth about most test pilots and flight test work is pretty boring by comparison to the movie image. Test pilots are first good system engineers, second skilled aviators and third calm and collected under pressure. Test flying itself is much more about planning - and planning for contingencies and contingencies for those contingencies  - than the actual flying itself.  Test flying is conducted according to more or less a rigid schedule developed by a flight test department.  A test pilot will fly the aircraft through specific test points and is expected to maneuver the aircraft in a very precise way - precise control inputs, precise altitudes, air speeds, angle of attack, flight maneuvers, etc. In order to collect test data for the flight test team.  The test pilot is also expected to be able to correctly evaluate how the aircraft or systems handled.  Also needed is an ability to accurately describe discrepancies in performance and handling to design engineer teams to correctly determine the root cause of these issues and address these problems correctly.

Safety is also paramount for doing flight test work.  Long gone are the days of strapping your little pink fanny into a crate, pushing it off a cliff and hoping for the best on the way down.  Test plans are thoroughly evaluated prior to flight for risks, mitigating factors and means to minimize those risks - and contingency plans should something go wrong.  I once heard a USN test pilot put it "we try to make the process as boring as possible."  Many test points will be attempted in simulators prior to the actual flight test and test pilots will have flown them many times, complete with conducting emergency procedures there.

Most test pilots don't even do experimental work; often times they are involved with manufacture flight test work.  This is usually involves simply testing all the systems of an existing production sample aircraft.  Other jobs test pilots are involved with are testing of new avionics, weapons, or mission systems aboard existing aircraft as part of the approval process for its use.