Let P be a hypoelliptic polynomial. We consider classes of ultradifferentiable functions with respect to the iterates of the partial differential operator P(D) and prove that such classes satisfy a Paley-Wiener type theorem. These classes and the corresponding test spaces are nuclear.