Repository: mne-tools/mne-python

Issue:
nosetests attempts ftp download
Hi,
I tried running nosetests via make, but it fails attempting a ftp download. I'm behind a hospital firewall and 
cannot use ftp (http downloads work fine via a proxy). Any suggestions?

If I only change documentation (docstrings and/or .rst), is it enough to run make test-doc?



Discussion:
yes it should be good. We'll polish it if needed

Does it get to running the tests, and the file-downloading test fails? Or does it try to download a dataset _before_ even running the tests? If it's the former, just ignore the failing download test -- the other tests are still valid. If it's the latter, you can run `nosetests -a '!slow_test' mne` (which is the second part in the Makefile).

You probably also want to run `nosetests mne/tests/test_docstring_parameters.py` to test some aspects of docstring formatting.

It was the former, but somehow the failed ftp download brought the whole thing down and the tests stopped running right there. I lost the console output, but I'll try it again.

[output.txt](https://github.com/mne-tools/mne-python/files/214502/output.txt)

Attached console output.

ERROR: Test file downloading is unrelated.

FAIL: Test Raw compensation by comparing with MNE is more problematic.
Maybe your sample dataset is not up to date?

Probably the testing dataset needs an update.

@jjnurminen okay to close this one? I think a test failing about FTP download is the right behavior if you can't actually download using FTP. If you really want to avoid seeing these failures, we could add a mne config like `MNE_SKIP_FTP_TESTS` that you and anyone else who can't use FTP could set to true.


Resolving patch:
diff --git a/mne/utils.py b/mne/utils.py
--- a/mne/utils.py
+++ b/mne/utils.py
@@ -787,6 +787,10 @@ def dec(*args, **kwargs):
     requires_module, name='good network connection',
     call='if int(os.environ.get("MNE_SKIP_NETWORK_TESTS", 0)):\n'
          '    raise ImportError')
+requires_ftp = partial(
+    requires_module, name='ftp downloading capability',
+    call='if int(os.environ.get("MNE_SKIP_FTP_TESTS", 0)):\n'
+         '    raise ImportError')
 requires_nitime = partial(requires_module, name='nitime',
                           call='import nitime')
 requires_traits = partial(requires_module, name='traits',
@@ -1175,6 +1179,8 @@ def set_memmap_min_size(memmap_min_size):
     'MNE_DATASETS_TESTING_PATH',
     'MNE_LOGGING_LEVEL',
     'MNE_MEMMAP_MIN_SIZE',
+    'MNE_SKIP_FTP_TESTS',
+    'MNE_SKIP_NETWORK_TESTS',
     'MNE_SKIP_TESTING_DATASET_TESTS',
     'MNE_STIM_CHANNEL',
     'MNE_USE_CUDA',


Test patch:
diff --git a/mne/tests/test_utils.py b/mne/tests/test_utils.py
--- a/mne/tests/test_utils.py
+++ b/mne/tests/test_utils.py
@@ -21,7 +21,7 @@
                        set_memmap_min_size, _get_stim_channel, _check_fname,
                        create_slices, _time_mask, random_permutation,
                        _get_call_line, compute_corr, sys_info, verbose,
-                       check_fname)
+                       check_fname, requires_ftp)
 
 
 warnings.simplefilter('always')  # enable b/c these tests throw warnings
@@ -393,30 +393,38 @@ def test_deprecated():
     assert_true(len(w) == 1)
 
 
-@requires_good_network
-def test_fetch_file():
-    """Test file downloading
-    """
+def _test_fetch(url):
+    """Helper to test URL retrieval"""
     tempdir = _TempDir()
-    urls = ['http://google.com',
-            'ftp://ftp.openbsd.org/pub/OpenBSD/README']
     with ArgvSetter(disable_stderr=False):  # to capture stdout
-        for url in urls:
-            archive_name = op.join(tempdir, "download_test")
-            _fetch_file(url, archive_name, timeout=30., verbose=False,
-                        resume=False)
-            assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS',
-                          op.join(tempdir, 'test'), verbose=False)
-            resume_name = op.join(tempdir, "download_resume")
-            # touch file
-            with open(resume_name + '.part', 'w'):
-                os.utime(resume_name + '.part', None)
-            _fetch_file(url, resume_name, resume=True, timeout=30.,
-                        verbose=False)
-            assert_raises(ValueError, _fetch_file, url, archive_name,
-                          hash_='a', verbose=False)
-            assert_raises(RuntimeError, _fetch_file, url, archive_name,
-                          hash_='a' * 32, verbose=False)
+        archive_name = op.join(tempdir, "download_test")
+        _fetch_file(url, archive_name, timeout=30., verbose=False,
+                    resume=False)
+        assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS',
+                      op.join(tempdir, 'test'), verbose=False)
+        resume_name = op.join(tempdir, "download_resume")
+        # touch file
+        with open(resume_name + '.part', 'w'):
+            os.utime(resume_name + '.part', None)
+        _fetch_file(url, resume_name, resume=True, timeout=30.,
+                    verbose=False)
+        assert_raises(ValueError, _fetch_file, url, archive_name,
+                      hash_='a', verbose=False)
+        assert_raises(RuntimeError, _fetch_file, url, archive_name,
+                      hash_='a' * 32, verbose=False)
+
+
+@requires_good_network
+def test_fetch_file_html():
+    """Test file downloading over http"""
+    _test_fetch('http://google.com')
+
+
+@requires_ftp
+@requires_good_network
+def test_fetch_file_ftp():
+    """Test file downloading over ftp"""
+    _test_fetch('ftp://speedtest.tele2.net/1KB.zip')
 
 
 def test_sum_squared():