Repository: scikit-image/scikit-image

Issue:
Please add info how to run the skimage unit tests at the end of the installation instructions
I couldn't find instructions how to run the skimage unit tests.

First I tried

```
python -c 'import skimage; skimage.test()
```

which ran 287 tests and gave 16 errors, all the same:

```
ImportError: cannot import name BytesIO
```

Then I tried

```
nosetests --exe skimage
```

which ran 490 tests, no error.

Full output is here: https://gist.github.com/3832077

Apparently it is important to not use `skimage.test()`, but `nosetests` instead?
Could you please add this info somewhere, the first place I would have looked is at the end of http://skimage.org/docs/dev/install.html ( or make "nosetests" or "run tests" in the sphinx search find the appropriate command to run).

Thanks!



Discussion:
@cdeil Are you sure that the `skimage` picked up on import is the same as the one found by nosetests?  I get exactly the same result either way.  `skimage.test` is supposed to simply invoke `nosetests` with the `--exe -w` flags.

I am pretty sure the same skimage is picked up by `skimage.test` and `nosetests`, because their output in both cases mentions
`/Users/deil/Library/Python/2.7/lib/python/site-packages/scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg/skimage` (see gist).

I am running all commands from `/tmp`, i.e. not from within the git repo.

I also noticed that if I use ipython instead of python, all tests pass:

```
ipython -c 'import skimage; skimage.test()'
```

Something is differents with imports when running via nose or ipython, so that this ImportError doesn't occur

```
======================================================================
ERROR: Failure: ImportError (cannot import name BytesIO)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/deil/Library/Python/2.7/lib/python/site-packages/scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg/skimage/color/tests/test_colorconv.py", line 20, in <module>
    from skimage.io import imread
  File "/Users/deil/Library/Python/2.7/lib/python/site-packages/scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg/skimage/io/__init__.py", line 14, in <module>
    from .collection import *
  File "/Users/deil/Library/Python/2.7/lib/python/site-packages/scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg/skimage/io/collection.py", line 12, in <module>
    from ._io import imread
  File "/Users/deil/Library/Python/2.7/lib/python/site-packages/scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg/skimage/io/_io.py", line 4, in <module>
    from io import BytesIO
  File "io/__init__.py", line 14, in <module>
    from .collection import *
  File "io/collection.py", line 12, in <module>
    from ._io import imread
  File "io/_io.py", line 4, in <module>
    from io import BytesIO
ImportError: cannot import name BytesIO
```

Maybe `skimage.io` and the python `io` are confused for some reason?

Btw., note that there is still the extra "s" in the name of the installed egg: `scikits_image-0.8dev-py2.7-macosx-10.8-x86_64.egg`

Try `python -c"import io;import skimage;skimage.test()"`. Works for me. Otherwise `skimage.io` shadows the builtin `io` module when running nose.

@cgohlke `python -c 'import io; import skimage; skimage.test()'` also works for me.

So what is the problem and fix for the imports inside skimage?
Why does this problem only appear when running the tests in this way and not during normal import of `skimage.io` in scripts / interactive sessions or when running `nostests -exe skimage` from the command line?

I'm interested because I've had similar problems with modules that have the same name as builtins in other projects, e.g. in https://github.com/rootpy/rootpy/issues/33


Resolving patch:
diff --git a/skimage/__init__.py b/skimage/__init__.py
--- a/skimage/__init__.py
+++ b/skimage/__init__.py
@@ -65,7 +65,7 @@
 def _setup_test(verbose=False):
     import functools
 
-    args = ['', '--exe', '-w', pkg_dir]
+    args = ['', pkg_dir, '--exe']
     if verbose:
         args.extend(['-v', '-s'])
 


Test patch: