Repository: sunpy/sunpy

Issue:
Tests which have hard coded numbers for web services fail often
There are various tests which expect a fixed number of results to come back from a webservice. This is especially the case in the database module. #1902 bodged this by expecting any change `>1`, a more proper workaround should really be developed.



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,19 +1,15 @@
 """
 Configuration file for the Sphinx documentation builder.
-
-isort:skip_file
 """
-# flake8: NOQA: E402
-
 # -- stdlib imports ------------------------------------------------------------
 import os
 import sys
 import datetime
+import warnings
 from pkg_resources import get_distribution
 from packaging.version import Version
 
 # -- Check for dependencies ----------------------------------------------------
-
 doc_requires = get_distribution("sunpy").requires(extras=("docs",))
 missing_requirements = []
 for requirement in doc_requires:
@@ -29,7 +25,6 @@
     sys.exit(1)
 
 # -- Read the Docs Specific Configuration --------------------------------------
-
 # This needs to be done before sunpy is imported
 on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
 if on_rtd:
@@ -40,16 +35,15 @@
     os.environ['HIDE_PARFIVE_PROGESS'] = 'True'
 
 # -- Non stdlib imports --------------------------------------------------------
-
 import ruamel.yaml as yaml  # NOQA
 from sphinx_gallery.sorting import ExplicitOrder  # NOQA
 from sphinx_gallery.sorting import ExampleTitleSortKey  # NOQA
 
 import sunpy  # NOQA
 from sunpy import __version__  # NOQA
+from sunpy.util.exceptions import SunpyDeprecationWarning, SunpyPendingDeprecationWarning  # NOQA
 
 # -- Project information -------------------------------------------------------
-
 project = 'SunPy'
 author = 'The SunPy Community'
 copyright = '{}, {}'.format(datetime.datetime.now().year, author)
@@ -59,8 +53,16 @@
 sunpy_version = Version(__version__)
 is_release = not(sunpy_version.is_prerelease or sunpy_version.is_devrelease)
 
+# We want to ignore all warnings in a release version.
+if is_release:
+    warnings.simplefilter("ignore")
+warnings.filterwarnings("error", category=SunpyDeprecationWarning)
+warnings.filterwarnings("error", category=SunpyPendingDeprecationWarning)
+# TODO: Remove this when we remove instr in sunpy 3.1
+warnings.filterwarnings(
+    "ignore", message="sunpy.instr is deprecated and will be removed in sunpy 3.1.", category=SunpyDeprecationWarning
+)
 # -- SunPy Sample Data and Config ----------------------------------------------
-
 # We set the logger to debug so that we can see any sample data download errors
 # in the CI, especially RTD.
 ori_level = sunpy.log.level
@@ -85,7 +87,6 @@
 """
 
 # -- General configuration -----------------------------------------------------
-
 # Suppress warnings about overriding directives as we overload some of the
 # doctest extensions.
 suppress_warnings = ['app.add_directive', ]
@@ -147,7 +148,6 @@
 napoleon_google_docstring = False
 
 # -- Options for intersphinx extension -----------------------------------------
-
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {
     "python": (
@@ -178,7 +178,6 @@
 }
 
 # -- Options for HTML output ---------------------------------------------------
-
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
 
@@ -202,7 +201,8 @@
 ]
 
 # -- Sphinx Gallery ------------------------------------------------------------
-
+# JSOC email os env
+os.environ["JSOC_EMAIL"] = "jsoc@cadair.com"
 sphinx_gallery_conf = {
     'backreferences_dir': os.path.join('generated', 'modules'),
     'filename_pattern': '^((?!skip_).)*$',
@@ -231,7 +231,6 @@
 }
 
 # -- Stability Page ------------------------------------------------------------
-
 with open('./code_ref/sunpy_stability.yaml', 'r') as estability:
     sunpy_modules = yaml.load(estability.read(), Loader=yaml.Loader)
 
@@ -257,12 +256,7 @@ def rstjinja(app, docname, source):
         source[0] = rendered
 
 
-# JSOC email os env
-os.environ["JSOC_EMAIL"] = "jsoc@cadair.com"
-
 # -- Sphinx setup --------------------------------------------------------------
-
-
 def setup(app):
     # Generate the stability page
     app.connect("source-read", rstjinja)
diff --git a/examples/map/composite_map_AIA_HMI.py b/examples/map/composite_map_AIA_HMI.py
--- a/examples/map/composite_map_AIA_HMI.py
+++ b/examples/map/composite_map_AIA_HMI.py
@@ -30,7 +30,6 @@
 hmi_smap = hmi_map.submap(SkyCoord(*bottom_left, frame=hmi_map.coordinate_frame),
                           top_right=SkyCoord(*top_right, frame=hmi_map.coordinate_frame))
 
-
 ##############################################################################
 # Let's create a `~sunpy.map.CompositeMap` which includes both maps.
 
diff --git a/examples/plotting/plotting_blank_map.py b/examples/plotting/plotting_blank_map.py
--- a/examples/plotting/plotting_blank_map.py
+++ b/examples/plotting/plotting_blank_map.py
@@ -56,8 +56,6 @@
 ################################################################################
 # Place and mark coordinates on the plot.
 
-# sphinx_gallery_defer_figures
-
 coords = SkyCoord(xc, yc, frame=blank_map.coordinate_frame)
 p = ax.plot_coord(coords, 'o')
 # Set title.


Test patch:
diff --git a/sunpy/database/tests/test_database.py b/sunpy/database/tests/test_database.py
--- a/sunpy/database/tests/test_database.py
+++ b/sunpy/database/tests/test_database.py
@@ -450,9 +450,7 @@ def test_add_entry_from_hek_qr(database):
         hek.attrs.EventType('FL'))
     assert len(database) == 0
     database.add_from_hek_query_result(hek_res)
-    # This number loves to change, so we are just going to test that it's added
-    # *something*
-    assert len(database) > 1
+    assert len(database) == 90
 
 
 @pytest.mark.remote_data
diff --git a/sunpy/net/dataretriever/sources/tests/test_noaa.py b/sunpy/net/dataretriever/sources/tests/test_noaa.py
--- a/sunpy/net/dataretriever/sources/tests/test_noaa.py
+++ b/sunpy/net/dataretriever/sources/tests/test_noaa.py
@@ -167,10 +167,10 @@ def test_srs_unpack():
 @pytest.mark.remote_data
 def test_srs_midyear():
     qr = Fido.search(a.Instrument("soon") & a.Time("2011/06/07", "2011/06/08T23:59:29"))
-    res = Fido.fetch(qr)
+    res = sorted(Fido.fetch(qr))
     assert len(res) == 2
-    assert res.data[0].endswith("20110607SRS.txt")
-    assert res.data[-1].endswith("20110608SRS.txt")
+    assert res[0].endswith("20110607SRS.txt")
+    assert res[-1].endswith("20110608SRS.txt")
 
 
 @no_vso