fix maps/hpxmap.rst
@@ -16,7 +16,7 @@ the pixel size (NSIDE), coordinate system, and definition of non-spatial axes
(e.g. energy). By default a HEALPix geometry will encompass the full sky. The
following example shows how to create an all-sky 2D HEALPix image:
-.. code-block:: python
+.. testcode::
from gammapy.maps import HpxGeom, HpxNDMap, HpxMap
# Create a HEALPix geometry of NSIDE=16
@@ -30,7 +30,7 @@ Partial-sky maps can be created by passing a ``region`` argument to the map
geometry constructor or by setting the ``width`` argument to the
`~gammapy.maps.HpxMap.create` factory method:
-.. code-block:: python
+.. testcode::
from gammapy.maps import HpxGeom, HpxMap, HpxNDMap
from astropy.coordinates import SkyCoord
