Repository: sunpy/sunpy

Issue:
sunpy.data.manager does not allow for local path object in manager. override_file()
<!-- This comments are hidden when you submit the issue so you do not need to remove them!
Please be sure to check out our contributing guidelines: https://github.com/sunpy/sunpy/blob/master/CONTRIBUTING.rst
Please be sure to check out our code of conduct:
https://github.com/sunpy/sunpy/blob/master/CODE_OF_CONDUCT.rst -->

<!-- Please have a search on our GitHub repository to see if a similar issue has already been posted.
If a similar issue is closed, have a quick look to see if you are satisfied by the resolution.
If not please go ahead and open an issue! -->

### Description
It would be great if `sunpy.data.manager` could take a local file path





Discussion:
oh no wait it does seem to be working ....

Resolving patch:
diff --git a/sunpy/data/data_manager/manager.py b/sunpy/data/data_manager/manager.py
--- a/sunpy/data/data_manager/manager.py
+++ b/sunpy/data/data_manager/manager.py
@@ -1,11 +1,12 @@
-from typing import Dict
 import pathlib
+import warnings
 import functools
+from typing import Dict
 from contextlib import contextmanager
-import warnings
+from urllib.parse import urlparse
 
-from sunpy.util.util import hash_file
 from sunpy.util.exceptions import SunpyUserWarning
+from sunpy.util.util import hash_file
 
 __all__ = ['DataManager']
 
@@ -50,8 +51,14 @@ def decorator(func):
             def wrapper(*args, **kwargs):
                 replace = self._skip_file.get(name, None)
                 if replace:
-                    if replace['uri'].startswith('file://'):
-                        file_path = replace['uri'][len('file://'):]
+                    uri_parse = urlparse(replace['uri'])
+                    if uri_parse.scheme in ("", "file"):
+                        # If a relative file uri is specified (i.e.
+                        # `file://sunpy/test`) this maintains compatibility
+                        # with the original behaviour where this would be
+                        # interpreted as `./sunpy/test` if no scheme is
+                        # specified netloc will be '' by default.
+                        file_path = uri_parse.netloc + uri_parse.path
                         file_hash = hash_file(file_path)
                     else:
                         file_path, file_hash, _ = self._cache._download_and_hash([replace['uri']])
@@ -74,11 +81,13 @@ def wrapper(*args, **kwargs):
                         if hash_file(file_path) != sha_hash:
                             # the hash of the file downloaded does not match provided hash
                             # this means the file has changed on the server.
-                            # the function should be updated to use the new hash. Raise an error to notify.
+                            # the function should be updated to use the new
+                            # hash. Raise an error to notify.
                             raise RuntimeError(
                                 "Remote file on the server has changed. Update hash of the function.")
                     else:
-                        # This is to handle the case when the local file appears to be tampered/corrupted
+                        # This is to handle the case when the local file
+                        # appears to be tampered/corrupted
                         if hash_file(details['file_path']) != details['file_hash']:
                             warnings.warn("Hashes do not match, the file will be redownloaded (could be be tampered/corrupted)",
                                           SunpyUserWarning)
@@ -106,8 +115,10 @@ def override_file(self, name, uri, sha_hash=None):
         name: `str`
             Name of the file provided in the `require` decorator.
         uri: `str`
-            URI of the file which replaces original file. Scheme should be
-            one of ``http``, ``https``, ``ftp`` or ``file``.
+            URI of the file which replaces original file. Scheme should be one
+            of ``http``, ``https``, ``ftp`` or ``file``. If no scheme is given
+            the uri will be interpreted as a local path. i.e.
+            ``file:///tmp/test`` and ``/tmp/test`` are the same.
         sha_hash: `str`, optional
             SHA256 hash of the file to compared to after downloading.
         """


Test patch:
diff --git a/sunpy/data/data_manager/tests/test_manager.py b/sunpy/data/data_manager/tests/test_manager.py
--- a/sunpy/data/data_manager/tests/test_manager.py
+++ b/sunpy/data/data_manager/tests/test_manager.py
@@ -88,6 +88,10 @@ def override_file_tester(manager):
         # Inside the file is replaced
         data_function(override_file_tester)
 
+    with manager.override_file('test_file', f'{folder}/another_file'):
+        # Inside the file is replaced
+        data_function(override_file_tester)
+
     # check the function works with hash provided
     with manager.override_file('test_file', f'file://{folder}/another_file', MOCK_HASH):
         data_function(override_file_tester)