While working on astropy.timeseries, I found that if one does:
.. doctest-requires:: pandas
>>> some code
then the doctest doesn't actually run even if the package (here pandas) is present, in the sense that the output could be wrong and it won't be picked up. Removing .. doctest-requires:: pandas, the doctest is run correctly provided pandas is installed.