kgrandis / nose-exclude

nose-exclude is a Nose plugin that allows you to easily specify directories to be excluded from testing. [OFFICIAL]
https://github.com/kgrandis/nose-exclude
GNU Lesser General Public License v2.1
21 stars 10 forks source link

DistutilsGetoptError: invalid long option 'exclude-dir=': must be a string of length >= 2 #4

Open mat128 opened 9 years ago

mat128 commented 9 years ago

When invoking through setup.py nosetests (instead of nosetests directly), the following error message is provided, even if no exclude dirs are specified.

py27 runtests: commands[0] | python setup.py nosetests Traceback (most recent call last): File "setup.py", line 3, in setup() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 138, in setup ok = dist.parse_command_line() File "/Users/mmitchell/projects/nose-exclude-demo/.tox/py27/lib/python2.7/site-packages/setuptools/dist.py", line 271, in parse_command_line result = _Distribution.parse_command_line(self) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 467, in parse_command_line args = self._parse_command_opts(parser, args) File "/Users/mmitchell/projects/nose-exclude-demo/.tox/py27/lib/python2.7/site-packages/setuptools/dist.py", line 555, in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 564, in _parse_command_opts (args, opts) = parser.getopt(args[1:]) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/fancy_getopt.py", line 253, in getopt self._grok_option_table() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/fancy_getopt.py", line 171, in _grok_option_table "must be a string of length >= 2") % long distutils.errors.DistutilsGetoptError: invalid long option 'exclude-dir=': must be a string of length >= 2 ERROR: InvocationError: '/Users/mmitchell/projects/nose-exclude-demo/.tox/py27/bin/python setup.py nosetests'

I setup a demo repository to reproduce the issue (simply run tox -r): https://github.com/mat128/nose-exclude-demo

And a travis-ci job to demonstrate it: https://travis-ci.org/mat128/nose-exclude-demo

This happens only after 0.4.0 was released. Thank you

kgrandis commented 9 years ago

Interesting. It looks like something related to the way I approached py3ification, unicode, and getopt. I'll need to investigate further.

That being said, I don't believe python setup.py nosetests ever worked error free since I include one always failing test that is only excluded through setup.py test using Nose's PluginTester.

mat128 commented 9 years ago

Worked great for us prior to last release. Maybe I can bring up a test case that installs 0.3.0... Let me check.

mat128 commented 9 years ago

Yup, worked on 0.3.0: https://travis-ci.org/mat128/nose-exclude-demo/builds/76495668 Let me know if there is anything else I can provide.

kgrandis commented 9 years ago

I don't know too much about the Travis environment (or maybe tox?), but it doesn't look like those builds are actually running any tests at all, whereas if I run the command from a shell (py27 @ 0.3.0) I get:

$ python setup.py nosetests
running nosetests
running egg_info
writing requirements to nose_exclude.egg-info/requires.txt
writing nose_exclude.egg-info/PKG-INFO
writing top-level names to nose_exclude.egg-info/top_level.txt
writing dependency_links to nose_exclude.egg-info/dependency_links.txt
writing entry points to nose_exclude.egg-info/entry_points.txt
reading manifest file 'nose_exclude.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'nose_exclude.egg-info/SOURCES.txt'
...F......nose.plugins.nose_exclude: WARNING: The following path was not found: --exclude-dir=test_dirs/test_i_dont_exist
............
======================================================================
FAIL: test.test_i_should_never_run
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kurt/.virtualenvs/noseexclude/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/kurt/sandbox/nose-exclude-git/test_dirs/test_not_me/test.py", line 3, in test_i_should_never_run
    assert False
AssertionError

----------------------------------------------------------------------
Ran 22 tests in 0.432s

FAILED (failures=1)

https://travis-ci.org/kgrandis/nose-exclude/jobs/76376881 (@0.4.0) shows tests being run. So, I do think even if I resolve this particular getopt issue once you tweak your configure to run the tests it'll still break.

kgrandis commented 9 years ago

I think if you wanted to use nosetests.py proper, you would need something like nosetests.py tests.py to keep nose from running down into the tests subdir that contain known failures or use something like nose-exclude :p

mat128 commented 9 years ago

In the travis test results, you dont see any test being run because I purposefully built the smallest possible test, providing only a virtualenv, nose and nose-exclude. Simply running this through setup.py nosetests (without specifying any exclude-dir) resulted in a crash.

I did more research and found new stuff:

kgrandis commented 9 years ago

excellent. thanks for the legwork. I'll review and try to get this released this weekend.