summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames J Lee <jjl@pobox.com>2008-05-05 12:17:35 +0000
committerJames J Lee <jjl@pobox.com>2008-05-05 12:17:35 +0000
commitd06e45589d9cfbbaa2a7d1728751ab647efb6b64 (patch)
tree04fbabf9bb06d7c62cdad94a07c24e27fc4dbf1d
parent4e812fb93e10d4143f51b4aa65ab34b641eac5f7 (diff)
downloadnose-d06e45589d9cfbbaa2a7d1728751ab647efb6b64.tar.gz
* Fix issue #184 (sys.argv[0] treated as option)
* Correct a docstring re default verbosity level
-rw-r--r--nose/config.py11
-rw-r--r--unit_tests/test_config.py12
2 files changed, 15 insertions, 8 deletions
diff --git a/nose/config.py b/nose/config.py
index 71dbe2e..738ef48 100644
--- a/nose/config.py
+++ b/nose/config.py
@@ -166,7 +166,7 @@ class Config(object):
self.stopOnError = env.get('NOSE_STOP', False)
self.stream = sys.stderr
self.testNames = ()
- self.verbosity = int(env.get('NOSE_VERBOSE', 0))
+ self.verbosity = int(env.get('NOSE_VERBOSE', 1))
self.where = ()
self.workingDir = None
"""
@@ -219,7 +219,7 @@ class Config(object):
for k in keys ])
__str__ = __repr__
- def _parseArgs(self, args, cfg_files):
+ def _parseArgs(self, argv, cfg_files):
def warn_sometimes(msg, name=None, filename=None):
if (hasattr(self.plugins, 'excludedOption') and
self.plugins.excludedOption(name)):
@@ -231,7 +231,7 @@ class Config(object):
raise ConfigError(msg)
parser = ConfiguredDefaultsOptionParser(
self.getParser(), self.configSection, file_error=warn_sometimes)
- return parser.parseArgsAndConfigFiles(args, cfg_files)
+ return parser.parseArgsAndConfigFiles(argv[1:], cfg_files)
def configure(self, argv=None, doc=None):
"""Configure the nose running environment. Execute configure before
@@ -250,9 +250,8 @@ class Config(object):
options, args = self._parseArgs(argv, options.files)
self.options = options
- tests = args[1:]
- if tests:
- self.testNames = tests
+ if args:
+ self.testNames = args
if options.testNames is not None:
self.testNames.extend(tolist(options.testNames))
diff --git a/unit_tests/test_config.py b/unit_tests/test_config.py
index 84f6464..47c597a 100644
--- a/unit_tests/test_config.py
+++ b/unit_tests/test_config.py
@@ -28,7 +28,7 @@ class TestNoseConfig(unittest.TestCase):
def test_multiple_include(self):
c = nose.config.Config()
- c.configure(['--include=a', '--include=b'])
+ c.configure(['program', '--include=a', '--include=b'])
self.assertEqual(len(c.include), 2)
a, b = c.include
assert a.match('a')
@@ -38,7 +38,7 @@ class TestNoseConfig(unittest.TestCase):
def test_single_include(self):
c = nose.config.Config()
- c.configure(['--include=b'])
+ c.configure(['program', '--include=b'])
self.assertEqual(len(c.include), 1)
b = c.include[0]
assert b.match('b')
@@ -72,5 +72,13 @@ class TestNoseConfig(unittest.TestCase):
self.assertEqual(c.workingDir, foo)
self.assertEqual(c.testNames, ['bar'])
+ def test_progname_looks_like_option(self):
+ # issue #184
+ c = nose.config.Config()
+ # the -v here is the program name, not an option
+ # this matters eg. with python -c "import nose; nose.main()"
+ c.configure(['-v', 'mytests'])
+ self.assertEqual(c.verbosity, 1)
+
if __name__ == '__main__':
unittest.main()