BUG: Make numpy import when run with Python flag '-OO'.

This consists of checking for a docstring equal to None and skipping two
tests that require docstrings.

Closes #5148.

Rebased for backport to 1.9.