Test fails with pytest 3.1
Since today we have two builds that fail on travis-ci in Gammapy:
https://travis-ci.org/gammapy/gammapy/jobs/238624107

As far as I can see, the cause is that those builds since today use the recently release pytest 3.1, which accidentally changed something about the warnings filter, and now 1000s of warnings appear and the builds on travis-ci fail because the log is too long.

Maybe this was fixed in the pytest 3.1.1 release two days ago?
https://docs.pytest.org/en/latest/changelog.html#pytest-3-1-1-2017-05-30

@bsipocz @astrofrog - Do you know anything about this? Is this seen for other Astropy packages too? Should we change something in Gammapy or `ci-helpers` or will simply waiting a few days resolve the issue, because  `pytest 3.1.1` makes it to the appropriate conda channel?
diff --git a/.travis.yml b/.travis.yml
index f17960c9f..ddf4e7631 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,6 +45,8 @@ env:
 
         - MAIN_CMD='python setup.py'
 
+        - ASTROPY_USE_SYSTEM_PYTEST=1
+
     matrix:
         - PYTHON_VERSION=3.6 SETUP_CMD='egg_info'
         - PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
diff --git a/appveyor.yml b/appveyor.yml
index 6cb83f9bc..20c293230 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -13,6 +13,7 @@ environment:
       CONDA_DEPENDENCIES: "Cython click pyyaml scipy jinja2 click scikit-image matplotlib"
       PIP_DEPENDENCIES: "regions"
       FETCH_GAMMAPY_EXTRA: true
+      ASTROPY_USE_SYSTEM_PYTEST: 1
 
   matrix:
       - PYTHON_VERSION: "2.7"
diff --git a/dev/check_psf_norm.py b/dev/check_psf_norm.py
index 76fb1677e..c961f14bd 100644
--- a/dev/check_psf_norm.py
+++ b/dev/check_psf_norm.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 
 
 # TODO: implement this test without executing ROOT
diff --git a/docs/development/howto.rst b/docs/development/howto.rst
index 7e72fb5dd..0613f5848 100644
--- a/docs/development/howto.rst
+++ b/docs/development/howto.rst
@@ -177,7 +177,7 @@ Skip unit tests for some Astropy versions
 .. code-block:: python
 
    import astropy
-   from astropy.tests.helper import pytest
+   import pytest
 
    ASTROPY_VERSION = (astropy.version.major, astropy.version.minor)
    @pytest.mark.xfail(ASTROPY_VERSION < (0, 4), reason="Astropy API change")
diff --git a/gammapy/astro/population/tests/test_spatial.py b/gammapy/astro/population/tests/test_spatial.py
index d84dcb2d4..77956324f 100644
--- a/gammapy/astro/population/tests/test_spatial.py
+++ b/gammapy/astro/population/tests/test_spatial.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
-from astropy.tests.helper import pytest
+import pytest
 from astropy.modeling.tests.test_models import Fittable1DModelTester
 from ...population import (FaucherKaspi2006, Lorimer2006,
                            YusifovKucuk2004, YusifovKucuk2004B,
diff --git a/gammapy/background/tests/test_fov_cube.py b/gammapy/background/tests/test_fov_cube.py
index f61c541db..8cae660ab 100644
--- a/gammapy/background/tests/test_fov_cube.py
+++ b/gammapy/background/tests/test_fov_cube.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.units import Quantity
 from astropy.coordinates import Angle
 from ...utils.testing import requires_dependency, requires_data
diff --git a/gammapy/background/tests/test_models.py b/gammapy/background/tests/test_models.py
index 7173ee7b9..4f23caf1e 100644
--- a/gammapy/background/tests/test_models.py
+++ b/gammapy/background/tests/test_models.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose, assert_equal
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.table import Table
 import astropy.units as u
 from astropy.units import Quantity
diff --git a/gammapy/background/tests/test_reflected.py b/gammapy/background/tests/test_reflected.py
index 6e448af06..16f83cd5c 100644
--- a/gammapy/background/tests/test_reflected.py
+++ b/gammapy/background/tests/test_reflected.py
@@ -1,6 +1,8 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest, assert_quantity_allclose
+
+import pytest
+from astropy.tests.helper import assert_quantity_allclose
 from astropy.coordinates import SkyCoord, Angle
 from regions import CircleSkyRegion
 from ...utils.testing import requires_data, requires_dependency
diff --git a/gammapy/catalog/tests/test_core.py b/gammapy/catalog/tests/test_core.py
index 465476411..13da06eb6 100644
--- a/gammapy/catalog/tests/test_core.py
+++ b/gammapy/catalog/tests/test_core.py
@@ -3,7 +3,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 from collections import OrderedDict
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest, assert_quantity_allclose
+import pytest
+
+from astropy.tests.helper import assert_quantity_allclose
 from astropy.table import Table, Column
 from astropy.units import Quantity
 from ..core import SourceCatalog
diff --git a/gammapy/catalog/tests/test_fermi.py b/gammapy/catalog/tests/test_fermi.py
index dd277ed5e..163743944 100644
--- a/gammapy/catalog/tests/test_fermi.py
+++ b/gammapy/catalog/tests/test_fermi.py
@@ -3,7 +3,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 import numpy as np
 from numpy.testing import assert_allclose
 from astropy import units as u
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ..fermi import SourceCatalog3FGL, SourceCatalog2FHL, SourceCatalog1FHL, SourceCatalog3FHL
 from ...spectrum.models import (PowerLaw, LogParabola, ExponentialCutoffPowerLaw3FGL,
                                 PLSuperExpCutoff3FGL)
diff --git a/gammapy/catalog/tests/test_gammacat.py b/gammapy/catalog/tests/test_gammacat.py
index 916b1617d..e4fd07ad4 100644
--- a/gammapy/catalog/tests/test_gammacat.py
+++ b/gammapy/catalog/tests/test_gammacat.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 from collections import OrderedDict
 from numpy.testing import assert_allclose
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy import units as u
 from ...utils.testing import requires_data, requires_dependency
 from ..gammacat import SourceCatalogGammaCat
diff --git a/gammapy/catalog/tests/test_others.py b/gammapy/catalog/tests/test_others.py
index 08ae54e52..9dd666368 100644
--- a/gammapy/catalog/tests/test_others.py
+++ b/gammapy/catalog/tests/test_others.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data
 from ... import datasets
 
diff --git a/gammapy/catalog/tests/test_registry.py b/gammapy/catalog/tests/test_registry.py
index 91e5c3e58..47ccdf2c3 100644
--- a/gammapy/catalog/tests/test_registry.py
+++ b/gammapy/catalog/tests/test_registry.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data
 from ..registry import source_catalogs, SourceCatalogRegistry
 from .test_core import make_test_catalog
diff --git a/gammapy/catalog/tests/test_snrcat.py b/gammapy/catalog/tests/test_snrcat.py
index 49baab5e7..1f2775737 100644
--- a/gammapy/catalog/tests/test_snrcat.py
+++ b/gammapy/catalog/tests/test_snrcat.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data
 from ..snrcat import SourceCatalogSNRcat
 
diff --git a/gammapy/cube/tests/test_images.py b/gammapy/cube/tests/test_images.py
index ed6d2bdc0..406538371 100644
--- a/gammapy/cube/tests/test_images.py
+++ b/gammapy/cube/tests/test_images.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_array_equal, assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.io import fits
 from astropy import units as u
 from ...datasets import FermiGalacticCenter
diff --git a/gammapy/data/tests/test_data_manager.py b/gammapy/data/tests/test_data_manager.py
index 37173dd54..357bfba73 100644
--- a/gammapy/data/tests/test_data_manager.py
+++ b/gammapy/data/tests/test_data_manager.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data, data_manager, requires_dependency
 
 
diff --git a/gammapy/data/tests/test_data_store.py b/gammapy/data/tests/test_data_store.py
index befcb5a41..e78547ea6 100644
--- a/gammapy/data/tests/test_data_store.py
+++ b/gammapy/data/tests/test_data_store.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose, assert_equal
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.coordinates import Angle, SkyCoord
 from astropy.units import Quantity
 import astropy.units as u
diff --git a/gammapy/data/tests/test_event_list.py b/gammapy/data/tests/test_event_list.py
index 8c523a36e..578273837 100644
--- a/gammapy/data/tests/test_event_list.py
+++ b/gammapy/data/tests/test_event_list.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
 from astropy.coordinates import Angle, SkyCoord
-from astropy.tests.helper import pytest
+import pytest
 from regions import CircleSkyRegion
 from ...utils.testing import requires_dependency, requires_data
 from ...data import EventList, EventListDataset, EventListDatasetChecker
diff --git a/gammapy/data/tests/test_hdu_index_table.py b/gammapy/data/tests/test_hdu_index_table.py
index 09018b2eb..c5fc86c3c 100644
--- a/gammapy/data/tests/test_hdu_index_table.py
+++ b/gammapy/data/tests/test_hdu_index_table.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ..hdu_index_table import HDUIndexTable
 from ...utils.testing import requires_data
 
diff --git a/gammapy/data/tests/test_obs_stats.py b/gammapy/data/tests/test_obs_stats.py
index 857da8b68..b3d3b3262 100644
--- a/gammapy/data/tests/test_obs_stats.py
+++ b/gammapy/data/tests/test_obs_stats.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.coordinates import SkyCoord
 import astropy.units as u
 from regions import CircleSkyRegion
diff --git a/gammapy/data/tests/test_obs_summary.py b/gammapy/data/tests/test_obs_summary.py
index a3d14eeb2..f22cdb6e9 100644
--- a/gammapy/data/tests/test_obs_summary.py
+++ b/gammapy/data/tests/test_obs_summary.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.coordinates import SkyCoord
 import astropy.units as u
 from regions import CircleSkyRegion
diff --git a/gammapy/data/tests/test_pointing.py b/gammapy/data/tests/test_pointing.py
index a6f2b07cc..e49098a99 100644
--- a/gammapy/data/tests/test_pointing.py
+++ b/gammapy/data/tests/test_pointing.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data
 from ..pointing import PointingInfo
 
diff --git a/gammapy/datasets/tests/test_fermi.py b/gammapy/datasets/tests/test_fermi.py
index e3e58da00..dfc6b295d 100644
--- a/gammapy/datasets/tests/test_fermi.py
+++ b/gammapy/datasets/tests/test_fermi.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing.utils import assert_allclose
 from astropy import units as u
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.units import Quantity
 from astropy.coordinates import Angle
 
diff --git a/gammapy/datasets/tests/test_make.py b/gammapy/datasets/tests/test_make.py
index 287fd5314..b86001806 100644
--- a/gammapy/datasets/tests/test_make.py
+++ b/gammapy/datasets/tests/test_make.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import os
 import numpy as np
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.coordinates import Angle
 from astropy.units import Quantity
 from ...datasets import (make_test_psf, make_test_observation_table,
diff --git a/gammapy/detect/tests/test_matched_filter.py b/gammapy/detect/tests/test_matched_filter.py
index ecb2957ae..3d5ef49d6 100644
--- a/gammapy/detect/tests/test_matched_filter.py
+++ b/gammapy/detect/tests/test_matched_filter.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.convolution import Gaussian2DKernel
 from ...utils.testing import requires_dependency
 from ...detect import matched_filter
diff --git a/gammapy/image/models/tests/test_shapes.py b/gammapy/image/models/tests/test_shapes.py
index 364a5d7c7..20b4d5587 100644
--- a/gammapy/image/models/tests/test_shapes.py
+++ b/gammapy/image/models/tests/test_shapes.py
@@ -1,8 +1,9 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
+
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.modeling.tests.test_models import Fittable2DModelTester
 from ..models import Delta2D, Gaussian2D, Sphere2D, Shell2D, Template2D
 from ....utils.testing import requires_dependency, requires_data
diff --git a/gammapy/image/models/tests/test_theta.py b/gammapy/image/models/tests/test_theta.py
index 8b8c02f3f..8c2c50c32 100644
--- a/gammapy/image/models/tests/test_theta.py
+++ b/gammapy/image/models/tests/test_theta.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_almost_equal
-from astropy.tests.helper import pytest
+import pytest
 from ....utils.testing import requires_dependency
 from ...models import Gauss2DPDF, MultiGauss2D, ThetaCalculator, ThetaCalculatorScipy
 
diff --git a/gammapy/image/tests/test_core.py b/gammapy/image/tests/test_core.py
index f2f23d228..e90cc5117 100644
--- a/gammapy/image/tests/test_core.py
+++ b/gammapy/image/tests/test_core.py
@@ -7,7 +7,8 @@ from astropy.coordinates import SkyCoord, Angle
 from astropy.io import fits
 from astropy import units as u
 from astropy.units import Quantity
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.wcs import WcsError
 from regions import PixCoord, CirclePixelRegion, CircleSkyRegion
 from ...utils.testing import requires_dependency, requires_data
diff --git a/gammapy/image/tests/test_lists.py b/gammapy/image/tests/test_lists.py
index e929e167c..acbfbb388 100644
--- a/gammapy/image/tests/test_lists.py
+++ b/gammapy/image/tests/test_lists.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...image import SkyImageList, SkyImage
 
 
diff --git a/gammapy/image/tests/test_profile.py b/gammapy/image/tests/test_profile.py
index e693bc60d..907e91d7d 100644
--- a/gammapy/image/tests/test_profile.py
+++ b/gammapy/image/tests/test_profile.py
@@ -4,7 +4,8 @@ import numpy as np
 from numpy.testing import assert_allclose
 from astropy.table import Table
 from astropy import units as u
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.coordinates import Angle
 from ...utils.testing import requires_dependency, requires_data
 from ...datasets import FermiGalacticCenter
diff --git a/gammapy/image/tests/test_utils.py b/gammapy/image/tests/test_utils.py
index c73c0b6ee..777d2c381 100644
--- a/gammapy/image/tests/test_utils.py
+++ b/gammapy/image/tests/test_utils.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.wcs import WCS
 from ...utils.testing import requires_dependency, requires_data
 from ...datasets import FermiGalacticCenter
diff --git a/gammapy/irf/tests/test_fits_prod.py b/gammapy/irf/tests/test_fits_prod.py
index b8cdc9dad..297299610 100644
--- a/gammapy/irf/tests/test_fits_prod.py
+++ b/gammapy/irf/tests/test_fits_prod.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 import astropy.units as u
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...utils.testing import requires_dependency, requires_data, data_manager
 
 productions = [
diff --git a/gammapy/irf/tests/test_psf_analytical.py b/gammapy/irf/tests/test_psf_analytical.py
index 1801a2836..bea69bfbd 100644
--- a/gammapy/irf/tests/test_psf_analytical.py
+++ b/gammapy/irf/tests/test_psf_analytical.py
@@ -5,7 +5,7 @@ from numpy.testing.utils import assert_allclose
 from astropy.utils.data import get_pkg_data_filename
 from astropy.io import fits
 from astropy.units import Quantity
-from astropy.tests.helper import pytest
+import pytest
 from astropy.coordinates import Angle
 from ...utils.testing import requires_dependency, requires_data
 from ...irf import EnergyDependentMultiGaussPSF
diff --git a/gammapy/irf/tests/test_psf_king.py b/gammapy/irf/tests/test_psf_king.py
index 9eb397927..b6f068bf4 100644
--- a/gammapy/irf/tests/test_psf_king.py
+++ b/gammapy/irf/tests/test_psf_king.py
@@ -1,7 +1,8 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.units import Quantity
 from astropy.coordinates import Angle
 from ...utils.testing import requires_data
diff --git a/gammapy/irf/tests/test_psf_table.py b/gammapy/irf/tests/test_psf_table.py
index 20221ce08..1c73151c8 100644
--- a/gammapy/irf/tests/test_psf_table.py
+++ b/gammapy/irf/tests/test_psf_table.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.units import Quantity
 from astropy.coordinates import Angle
 from ...utils.testing import requires_dependency, requires_data
diff --git a/gammapy/maps/tests/test_hpx.py b/gammapy/maps/tests/test_hpx.py
index b64cf2144..c52c67de0 100644
--- a/gammapy/maps/tests/test_hpx.py
+++ b/gammapy/maps/tests/test_hpx.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from astropy.io import fits
 from ..hpx import HPXGeom, get_pixel_size_from_nside, nside_to_order
 from ..hpx import make_hpx_to_wcs_mapping, unravel_hpx_index, ravel_hpx_index
diff --git a/gammapy/scripts/tests/test_all.py b/gammapy/scripts/tests/test_all.py
index 4b5024231..973bd662e 100644
--- a/gammapy/scripts/tests/test_all.py
+++ b/gammapy/scripts/tests/test_all.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.scripts import get_all_main_functions
 
 SCRIPTS = get_all_main_functions()
diff --git a/gammapy/scripts/tests/test_catalog_query.py b/gammapy/scripts/tests/test_catalog_query.py
index 15951beb3..0bbbbad8f 100644
--- a/gammapy/scripts/tests/test_catalog_query.py
+++ b/gammapy/scripts/tests/test_catalog_query.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data, run_cli
 from ..catalog_query import cli
 
diff --git a/gammapy/scripts/tests/test_cta_utils.py b/gammapy/scripts/tests/test_cta_utils.py
index c8ff74a9b..ee1135881 100644
--- a/gammapy/scripts/tests/test_cta_utils.py
+++ b/gammapy/scripts/tests/test_cta_utils.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import astropy.units as u
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data, requires_dependency
 from ...scripts.cta_irf import CTAPerf
 from ...scripts.cta_utils import Target, ObservationParameters, CTAObservationSimulation
diff --git a/gammapy/scripts/tests/test_data_select.py b/gammapy/scripts/tests/test_data_select.py
index 5204396f4..00732a267 100644
--- a/gammapy/scripts/tests/test_data_select.py
+++ b/gammapy/scripts/tests/test_data_select.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_data, run_cli
 from ...datasets import gammapy_extra
 from ...data import ObservationTable
diff --git a/gammapy/scripts/tests/test_image_fit.py b/gammapy/scripts/tests/test_image_fit.py
index 4f6762f72..0b23eedde 100644
--- a/gammapy/scripts/tests/test_image_fit.py
+++ b/gammapy/scripts/tests/test_image_fit.py
@@ -2,8 +2,9 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import json
 from numpy.testing.utils import assert_allclose
+import pytest
+
 from astropy.stats import gaussian_sigma_to_fwhm
-from astropy.tests.helper import pytest
 from ...utils.testing import requires_dependency, requires_data
 from ...datasets import load_poisson_stats_image
 from ..image_fit import run_image_fit_sherpa
diff --git a/gammapy/scripts/tests/test_image_ts.py b/gammapy/scripts/tests/test_image_ts.py
index 276e71ec5..b76f050b2 100644
--- a/gammapy/scripts/tests/test_image_ts.py
+++ b/gammapy/scripts/tests/test_image_ts.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing.utils import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_dependency, requires_data
 from ...image import SkyImageList
 from ..image_ts import image_ts_main
diff --git a/gammapy/spectrum/tests/test_core.py b/gammapy/spectrum/tests/test_core.py
index 5edb93296..45e67dfb2 100644
--- a/gammapy/spectrum/tests/test_core.py
+++ b/gammapy/spectrum/tests/test_core.py
@@ -3,7 +3,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 from numpy.testing import assert_allclose
 import numpy as np
 import astropy.units as u
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...utils.testing import requires_dependency
 from ...utils.energy import EnergyBounds
 from .. import CountsSpectrum, PHACountsSpectrum
diff --git a/gammapy/spectrum/tests/test_crab.py b/gammapy/spectrum/tests/test_crab.py
index 888e4a5da..b6062fa84 100644
--- a/gammapy/spectrum/tests/test_crab.py
+++ b/gammapy/spectrum/tests/test_crab.py
@@ -1,7 +1,8 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import astropy.units as u
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...spectrum import CrabSpectrum
 
 CRAB_SPECTRA = [
diff --git a/gammapy/spectrum/tests/test_energy_group.py b/gammapy/spectrum/tests/test_energy_group.py
index de776637b..2d2ede507 100644
--- a/gammapy/spectrum/tests/test_energy_group.py
+++ b/gammapy/spectrum/tests/test_energy_group.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose, assert_equal
 import astropy.units as u
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...utils.testing import requires_dependency, requires_data
 from ..observation import SpectrumObservation
 from ..energy_group import SpectrumEnergyGroupMaker, calculate_flux_point_binning
diff --git a/gammapy/spectrum/tests/test_extract.py b/gammapy/spectrum/tests/test_extract.py
index 41a137543..400c172f0 100644
--- a/gammapy/spectrum/tests/test_extract.py
+++ b/gammapy/spectrum/tests/test_extract.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 import astropy.units as u
 from astropy.tests.helper import assert_quantity_allclose
 from ...utils.testing import requires_dependency, requires_data
diff --git a/gammapy/spectrum/tests/test_fit.py b/gammapy/spectrum/tests/test_fit.py
index d9398686a..ed2eae62c 100644
--- a/gammapy/spectrum/tests/test_fit.py
+++ b/gammapy/spectrum/tests/test_fit.py
@@ -1,6 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 import astropy.units as u
 import numpy as np
 from numpy.testing import assert_allclose
diff --git a/gammapy/spectrum/tests/test_flux_point.py b/gammapy/spectrum/tests/test_flux_point.py
index 193e4859f..65f235532 100644
--- a/gammapy/spectrum/tests/test_flux_point.py
+++ b/gammapy/spectrum/tests/test_flux_point.py
@@ -3,7 +3,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 import numpy as np
 from numpy.testing import assert_allclose
 from astropy.units import Quantity
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.table import Table
 import astropy.units as u
 from ...utils.testing import requires_dependency, requires_data
diff --git a/gammapy/spectrum/tests/test_models.py b/gammapy/spectrum/tests/test_models.py
index 54b8b1175..95f1e7778 100644
--- a/gammapy/spectrum/tests/test_models.py
+++ b/gammapy/spectrum/tests/test_models.py
@@ -2,7 +2,8 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import astropy.units as u
 from gammapy.utils.energy import EnergyBounds
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ..models import (PowerLaw, PowerLaw2, ExponentialCutoffPowerLaw,
                       ExponentialCutoffPowerLaw3FGL, LogParabola,
                       TableModel, AbsorbedSpectralModel, Absorption)
diff --git a/gammapy/spectrum/tests/test_obs_group.py b/gammapy/spectrum/tests/test_obs_group.py
index 10da3925a..5ef9566ea 100644
--- a/gammapy/spectrum/tests/test_obs_group.py
+++ b/gammapy/spectrum/tests/test_obs_group.py
@@ -1,6 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...utils.testing import requires_data, requires_dependency
 from ...data import ObservationTable
 from ...datasets import gammapy_extra
diff --git a/gammapy/spectrum/tests/test_utils.py b/gammapy/spectrum/tests/test_utils.py
index cad605ce6..0389c1d18 100644
--- a/gammapy/spectrum/tests/test_utils.py
+++ b/gammapy/spectrum/tests/test_utils.py
@@ -3,7 +3,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 import numpy as np
 from numpy.testing import assert_allclose
 from astropy.units import Quantity
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from ...utils.testing import requires_dependency
 from ...irf import EffectiveAreaTable, EnergyDispersion
 from ...spectrum import LogEnergyAxis, integrate_spectrum, CountsPredictor
diff --git a/gammapy/stats/tests/test_data.py b/gammapy/stats/tests/test_data.py
index 9f1404035..6667c592c 100644
--- a/gammapy/stats/tests/test_data.py
+++ b/gammapy/stats/tests/test_data.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...stats import Stats
 
 
diff --git a/gammapy/stats/tests/test_feldman_cousins.py b/gammapy/stats/tests/test_feldman_cousins.py
index 6b666d515..3b9f59d4f 100755
--- a/gammapy/stats/tests/test_feldman_cousins.py
+++ b/gammapy/stats/tests/test_feldman_cousins.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_dependency
 from ...stats import (
     fc_find_acceptance_interval_gauss,
diff --git a/gammapy/stats/tests/test_fit_statistics.py b/gammapy/stats/tests/test_fit_statistics.py
index 0178b0f4c..06bd51e40 100644
--- a/gammapy/stats/tests/test_fit_statistics.py
+++ b/gammapy/stats/tests/test_fit_statistics.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_dependency
 from ...utils.random import get_random_state
 from ... import stats
diff --git a/gammapy/stats/tests/test_poisson.py b/gammapy/stats/tests/test_poisson.py
index 582f4cbae..194e6abcf 100755
--- a/gammapy/stats/tests/test_poisson.py
+++ b/gammapy/stats/tests/test_poisson.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...stats import (
     background,
     background_error,
diff --git a/gammapy/stats/tests/test_significance.py b/gammapy/stats/tests/test_significance.py
index 38bddba2c..272a5b0a6 100644
--- a/gammapy/stats/tests/test_significance.py
+++ b/gammapy/stats/tests/test_significance.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_dependency
 from ...stats import (
     convert_likelihood,
diff --git a/gammapy/time/tests/test_lightcurve.py b/gammapy/time/tests/test_lightcurve.py
index d6d2b378c..5bc13031b 100644
--- a/gammapy/time/tests/test_lightcurve.py
+++ b/gammapy/time/tests/test_lightcurve.py
@@ -1,7 +1,8 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 from numpy.testing import assert_allclose
-from astropy.tests.helper import assert_quantity_allclose, pytest
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 from astropy.units import Quantity
 from astropy.coordinates import SkyCoord, Angle
 import astropy.units as u
diff --git a/gammapy/time/tests/test_plot.py b/gammapy/time/tests/test_plot.py
index 168ec02be..d5ba3953b 100644
--- a/gammapy/time/tests/test_plot.py
+++ b/gammapy/time/tests/test_plot.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 from ...utils.testing import requires_dependency, requires_data
 from ..plot import plot_fermi_3fgl_light_curve
 
diff --git a/gammapy/utils/distributions/tests/test_general_random.py b/gammapy/utils/distributions/tests/test_general_random.py
index e5104b051..e668cf24f 100644
--- a/gammapy/utils/distributions/tests/test_general_random.py
+++ b/gammapy/utils/distributions/tests/test_general_random.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
-from astropy.tests.helper import pytest
+import pytest
 from ....utils.distributions import GeneralRandom
 
 
diff --git a/gammapy/utils/root/tests/test_convert.py b/gammapy/utils/root/tests/test_convert.py
index f374e8929..3f893b64c 100644
--- a/gammapy/utils/root/tests/test_convert.py
+++ b/gammapy/utils/root/tests/test_convert.py
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
 from numpy.testing import assert_allclose
-from astropy.tests.helper import pytest
+import pytest
 
 HAS_ROOT = False
 
diff --git a/gammapy/utils/testing.py b/gammapy/utils/testing.py
index 2dae2de6e..97553e1a3 100644
--- a/gammapy/utils/testing.py
+++ b/gammapy/utils/testing.py
@@ -1,10 +1,12 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 """Utilities for testing"""
 from __future__ import absolute_import, division, print_function, unicode_literals
+
 import os
+import pytest
 from astropy.coordinates import Angle
-from astropy.tests.helper import pytest
 from numpy.testing import assert_array_less, assert_allclose
+
 from ..data import DataManager
 from ..datasets import gammapy_extra
 
diff --git a/gammapy/utils/tests/test_fits.py b/gammapy/utils/tests/test_fits.py
index b735d5460..842804bb9 100644
--- a/gammapy/utils/tests/test_fits.py
+++ b/gammapy/utils/tests/test_fits.py
@@ -1,7 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
 import numpy as np
-from astropy.tests.helper import pytest
+import pytest
 from astropy.io import fits
 from ..fits import (
     SmartHDUList,
diff --git a/gammapy/utils/tests/test_nddata.py b/gammapy/utils/tests/test_nddata.py
index 99d4df9dd..78eaa8f7b 100644
--- a/gammapy/utils/tests/test_nddata.py
+++ b/gammapy/utils/tests/test_nddata.py
@@ -1,6 +1,7 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest, assert_quantity_allclose
+from astropy.tests.helper import assert_quantity_allclose
+import pytest
 import numpy as np
 from numpy.testing import assert_allclose
 import astropy.units as u
diff --git a/gammapy/utils/tests/test_table.py b/gammapy/utils/tests/test_table.py
index 01bac77b0..b555ae717 100644
--- a/gammapy/utils/tests/test_table.py
+++ b/gammapy/utils/tests/test_table.py
@@ -1,6 +1,6 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
 from __future__ import absolute_import, division, print_function, unicode_literals
-from astropy.tests.helper import pytest
+import pytest
 import astropy.units as u
 from astropy.table import Table, QTable, Column
 from ..table import table_standardise_units_copy
diff --git a/setup.cfg b/setup.cfg
index 3ecbec73e..9b13fa943 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -11,6 +11,7 @@ show-response = 1
 minversion = 2.2
 norecursedirs = build docs/_build
 #doctest_plus = enabled
+addopts = -p no:warnings
 
 [ah_bootstrap]
 auto_use = True
['gammapy/catalog/tests/test_core.py', 'gammapy/utils/testing.py', 'gammapy/image/models/tests/test_theta.py', 'gammapy/time/tests/test_lightcurve.py', 'gammapy/background/tests/test_models.py', 'gammapy/stats/tests/test_feldman_cousins.py', 'gammapy/time/tests/test_plot.py', 'gammapy/data/tests/test_hdu_index_table.py', 'gammapy/spectrum/tests/test_extract.py', 'gammapy/data/tests/test_event_list.py', 'gammapy/utils/tests/test_table.py', '.travis.yml', 'gammapy/background/tests/test_reflected.py', 'gammapy/irf/tests/test_psf_king.py', 'gammapy/irf/tests/test_psf_table.py', 'gammapy/data/tests/test_data_store.py', 'gammapy/cube/tests/test_images.py', 'gammapy/maps/tests/test_hpx.py', 'gammapy/utils/root/tests/test_convert.py', 'gammapy/irf/tests/test_psf_analytical.py', 'gammapy/utils/tests/test_fits.py', 'gammapy/stats/tests/test_poisson.py', 'setup.cfg', 'gammapy/spectrum/tests/test_energy_group.py', 'gammapy/scripts/tests/test_data_select.py', 'gammapy/data/tests/test_obs_summary.py', 'gammapy/data/tests/test_data_manager.py', 'gammapy/datasets/tests/test_fermi.py', 'gammapy/scripts/tests/test_image_ts.py', 'gammapy/datasets/tests/test_make.py', 'gammapy/scripts/tests/test_cta_utils.py', 'gammapy/scripts/tests/test_image_fit.py', 'gammapy/stats/tests/test_significance.py', 'gammapy/image/tests/test_profile.py', 'gammapy/image/tests/test_lists.py', 'gammapy/scripts/tests/test_catalog_query.py', 'docs/development/howto.rst', 'gammapy/detect/tests/test_matched_filter.py', 'gammapy/spectrum/tests/test_utils.py', 'gammapy/data/tests/test_pointing.py', 'gammapy/spectrum/tests/test_crab.py', 'gammapy/utils/tests/test_nddata.py', 'gammapy/stats/tests/test_fit_statistics.py', 'gammapy/spectrum/tests/test_flux_point.py', 'gammapy/stats/tests/test_data.py', 'gammapy/irf/tests/test_fits_prod.py', 'gammapy/scripts/tests/test_all.py', 'dev/check_psf_norm.py', 'gammapy/astro/population/tests/test_spatial.py', 'gammapy/spectrum/tests/test_obs_group.py', 'gammapy/spectrum/tests/test_core.py', 'gammapy/catalog/tests/test_snrcat.py', 'gammapy/background/tests/test_fov_cube.py', 'appveyor.yml', 'gammapy/data/tests/test_obs_stats.py', 'gammapy/image/tests/test_core.py', 'gammapy/utils/distributions/tests/test_general_random.py', 'gammapy/catalog/tests/test_others.py', 'gammapy/spectrum/tests/test_models.py', 'gammapy/catalog/tests/test_gammacat.py', 'gammapy/image/tests/test_utils.py', 'gammapy/catalog/tests/test_registry.py', 'gammapy/spectrum/tests/test_fit.py', 'gammapy/image/models/tests/test_shapes.py', 'gammapy/catalog/tests/test_fermi.py']