prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Figure tests directory gets wiped after running via the test runner.
  Just discovered that when I run:
  ```bash
  python setup.py test --figure-only
  ```
  The resulting figure images are saved in a tmp directory that gets wiped at the end of the process (this is under linux for me)
  
  Using `pytest` adds the folder into my sunpy folder.
  
  
  
  </issue>
  <code>
  [start of sunpy/conftest.py]
  1 from __future__ import absolute_import, print_function
  2 from functools import partial
  3 
  4 import os
  5 import tempfile
  6 import json
  7 
  8 # Force MPL to use non-gui backends for testing.
  9 try:
  10     import matplotlib
  11 except ImportError:
  12     pass
  13 else:
  14     matplotlib.use('Agg')
  15 
  16 from sunpy.tests.hash import HASH_LIBRARY_NAME
  17 from sunpy.tests.helpers import new_hash_library, test_fig_dir
  18 from sunpy.extern import six
  19 
  20 import pytest
  21 
  22 
  23 # Don't actually import pytest_remotedata because that can do things to the
  24 # entrypoints code in pytest.
  25 if six.PY2:
  26     import imp
  27     try:
  28         imp.find_module('pytest_remotedata')
  29         HAVE_REMOTEDATA = True
  30     except ImportError:
  31         HAVE_REMOTEDATA = False
  32 else:
  33     import importlib
  34     remotedata_spec = importlib.util.find_spec("pytest_remotedata")
  35     HAVE_REMOTEDATA = remotedata_spec is not None
  36 
  37 
  38 def pytest_runtest_setup(item):
  39     """
  40     pytest hook to skip all tests that have the mark 'online' if the
  41     client is online (simply detected by checking whether http://www.google.com
  42     can be requested).
  43     """
  44     if isinstance(item, item.Function):
  45         if 'remote_data' in item.keywords and not HAVE_REMOTEDATA:
  46             pytest.skip("skipping remotedata tests as pytest-remotedata is not installed")
  47 
  48 
  49 def pytest_unconfigure(config):
  50     if len(new_hash_library) > 0:
  51         # Write the new hash library in JSON
  52         hashfile = os.path.join(test_fig_dir, HASH_LIBRARY_NAME)
  53         with open(hashfile, 'w') as outfile:
  54             json.dump(new_hash_library, outfile, sort_keys=True, indent=4, separators=(',', ': '))
  55 
  56         print('All images from image tests can be found in {0}'.format(test_fig_dir))
  57         print("The corresponding hash library is {0}".format(hashfile))
  58
  [end of sunpy/conftest.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/sunpy/conftest.py b/sunpy/conftest.py
  --- a/sunpy/conftest.py
  +++ b/sunpy/conftest.py
  @@ -13,8 +13,9 @@
   else:
       matplotlib.use('Agg')
   
  +import sunpy.tests.helpers
   from sunpy.tests.hash import HASH_LIBRARY_NAME
  -from sunpy.tests.helpers import new_hash_library, test_fig_dir
  +from sunpy.tests.helpers import new_hash_library
   from sunpy.extern import six
   
   import pytest
  @@ -35,6 +36,15 @@
       HAVE_REMOTEDATA = remotedata_spec is not None
   
   
  +def pytest_addoption(parser):
  +    parser.addoption("--figure_dir", action="store", default="./figure_test_images")
  +
  +
  +@pytest.fixture(scope='session', autouse=True)
  +def figure_base_dir(request):
  +    sunpy.tests.helpers.figure_base_dir = request.config.getoption("--figure_dir")
  +
  +
   def pytest_runtest_setup(item):
       """
       pytest hook to skip all tests that have the mark 'online' if the
  @@ -49,9 +59,10 @@
   def pytest_unconfigure(config):
       if len(new_hash_library) > 0:
           # Write the new hash library in JSON
  -        hashfile = os.path.join(test_fig_dir, HASH_LIBRARY_NAME)
  +        figure_base_dir = os.path.abspath(config.getoption("--figure_dir"))
  +        hashfile = os.path.join(figure_base_dir, HASH_LIBRARY_NAME)
           with open(hashfile, 'w') as outfile:
               json.dump(new_hash_library, outfile, sort_keys=True, indent=4, separators=(',', ': '))
   
  -        print('All images from image tests can be found in {0}'.format(test_fig_dir))
  +        print('All images from image tests can be found in {0}'.format(figure_base_dir))
           print("The corresponding hash library is {0}".format(hashfile))
  
verification_info: {"golden_diff": "diff --git a/sunpy/conftest.py b/sunpy/conftest.py\n--- a/sunpy/conftest.py\n+++ b/sunpy/conftest.py\n@@ -13,8 +13,9 @@\n else:\n     matplotlib.use('Agg')\n \n+import sunpy.tests.helpers\n from sunpy.tests.hash import HASH_LIBRARY_NAME\n-from sunpy.tests.helpers import new_hash_library, test_fig_dir\n+from sunpy.tests.helpers import new_hash_library\n from sunpy.extern import six\n \n import pytest\n@@ -35,6 +36,15 @@\n     HAVE_REMOTEDATA = remotedata_spec is not None\n \n \n+def pytest_addoption(parser):\n+    parser.addoption(\"--figure_dir\", action=\"store\", default=\"./figure_test_images\")\n+\n+\n+@pytest.fixture(scope='session', autouse=True)\n+def figure_base_dir(request):\n+    sunpy.tests.helpers.figure_base_dir = request.config.getoption(\"--figure_dir\")\n+\n+\n def pytest_runtest_setup(item):\n     \"\"\"\n     pytest hook to skip all tests that have the mark 'online' if the\n@@ -49,9 +59,10 @@\n def pytest_unconfigure(config):\n     if len(new_hash_library) > 0:\n         # Write the new hash library in JSON\n-        hashfile = os.path.join(test_fig_dir, HASH_LIBRARY_NAME)\n+        figure_base_dir = os.path.abspath(config.getoption(\"--figure_dir\"))\n+        hashfile = os.path.join(figure_base_dir, HASH_LIBRARY_NAME)\n         with open(hashfile, 'w') as outfile:\n             json.dump(new_hash_library, outfile, sort_keys=True, indent=4, separators=(',', ': '))\n \n-        print('All images from image tests can be found in {0}'.format(test_fig_dir))\n+        print('All images from image tests can be found in {0}'.format(figure_base_dir))\n         print(\"The corresponding hash library is {0}\".format(hashfile))\n", "issue": "Figure tests directory gets wiped after running via the test runner.\nJust discovered that when I run:\r\n```bash\r\npython setup.py test --figure-only\r\n```\r\nThe resulting figure images are saved in a tmp directory that gets wiped at the end of the process (this is under linux for me)\r\n\r\nUsing `pytest` adds the folder into my sunpy folder.\r\n\r\n\n", "before_files": [{"content": "from __future__ import absolute_import, print_function\nfrom functools import partial\n\nimport os\nimport tempfile\nimport json\n\n# Force MPL to use non-gui backends for testing.\ntry:\n    import matplotlib\nexcept ImportError:\n    pass\nelse:\n    matplotlib.use('Agg')\n\nfrom sunpy.tests.hash import HASH_LIBRARY_NAME\nfrom sunpy.tests.helpers import new_hash_library, test_fig_dir\nfrom sunpy.extern import six\n\nimport pytest\n\n\n# Don't actually import pytest_remotedata because that can do things to the\n# entrypoints code in pytest.\nif six.PY2:\n    import imp\n    try:\n        imp.find_module('pytest_remotedata')\n        HAVE_REMOTEDATA = True\n    except ImportError:\n        HAVE_REMOTEDATA = False\nelse:\n    import importlib\n    remotedata_spec = importlib.util.find_spec(\"pytest_remotedata\")\n    HAVE_REMOTEDATA = remotedata_spec is not None\n\n\ndef pytest_runtest_setup(item):\n    \"\"\"\n    pytest hook to skip all tests that have the mark 'online' if the\n    client is online (simply detected by checking whether http://www.google.com\n    can be requested).\n    \"\"\"\n    if isinstance(item, item.Function):\n        if 'remote_data' in item.keywords and not HAVE_REMOTEDATA:\n            pytest.skip(\"skipping remotedata tests as pytest-remotedata is not installed\")\n\n\ndef pytest_unconfigure(config):\n    if len(new_hash_library) > 0:\n        # Write the new hash library in JSON\n        hashfile = os.path.join(test_fig_dir, HASH_LIBRARY_NAME)\n        with open(hashfile, 'w') as outfile:\n            json.dump(new_hash_library, outfile, sort_keys=True, indent=4, separators=(',', ': '))\n\n        print('All images from image tests can be found in {0}'.format(test_fig_dir))\n        print(\"The corresponding hash library is {0}\".format(hashfile))\n", "path": "sunpy/conftest.py"}]}