1. Kevin Mitchell
  2. nose

Commits

jpellerin  committed 39abfc6

Improved option help display, some whitespace cleanups

  • Participants
  • Parent commits 82bcfcf
  • Branches default

Comments (0)

Files changed (15)

File doc/conf.py

View file
  • Ignore whitespace
     os.path.join(os.path.dirname(__file__), '..'))
 sys.path.insert(0, os.path.abspath('.'))
 
+
 # General configuration
 # ---------------------
 

File doc/manpage.py

View file
  • Ignore whitespace
         pass
 
     def visit_desc_name(self, node):
-        pass # option string
+        self.body.append(r'\fB') # option name
 
     def depart_desc_name(self, node):
-        pass
+        self.body.append(r'\fR')
 
     def visit_desc_addname(self, node):
-        pass # option default value
+        self.body.append(r'\fR')
 
     def depart_desc_addname(self, node):
+        # self.body.append(r'\fR')
         pass
 
     def visit_desc_content(self, node):

File nose/config.py

View file
  • Ignore whitespace
             help="Be more verbose. [NOSE_VERBOSE]")
         parser.add_option(
             "--verbosity", action="store", dest="verbosity",
+            metavar='VERBOSITY',
             type="int", help="Set verbosity; --verbosity=2 is "
             "the same as -v")
         parser.add_option(
             default=self.testMatchPat)
         parser.add_option(
             "--tests", action="store", dest="testNames", default=None,
+            metavar='NAMES',
             help="Run these tests (comma-separated list). This argument is "
             "useful mainly from configuration files; on the command line, "
             "just pass the tests to run as additional arguments with no "
             "nose.selector. Separate multiple names with a comma.")
         parser.add_option(
             "--debug-log", dest="debugLog", action="store",
-            default=self.debugLog,
+            default=self.debugLog, metavar="FILE",
             help="Log debug messages to this file "
             "(default: sys.stderr)")
         parser.add_option(
             "--logging-config", "--log-config",
             dest="loggingConfig", action="store",
-            default=self.loggingConfig,
+            default=self.loggingConfig, metavar="FILE",
             help="Load logging config from this file -- bypasses all other"
             " logging config settings.")
         parser.add_option(
             "-e", "--exclude", action="append", dest="exclude",
+            metavar="REGEX",
             help="Don't run tests that match regular "
             "expression [NOSE_EXCLUDE]")
         parser.add_option(
             "-i", "--include", action="append", dest="include",
+            metavar="REGEX",
             help="This regular expression will be applied to files, "
             "directories, function names, and class names for a chance "
             "to include additional tests that do not match TESTMATCH.  "

File nose/plugins/allmodules.py

View file
  • Ignore whitespace
 See also: :doc:`../doc_tests/test_allmodules/test_allmodules`
 
 .. warning ::
-  
+
    This plugin can have surprising interactions with plugins that load tests
    from what nose normally considers non-test modules, such as
    the :doc:`doctest plugin <doctests>`. This is because any given
    :class:`test loader <nose.loader.TestLoader>`. Also, if you have test-like
    functions or classes in non-test modules that are not tests, you will
    likely see errors as nose attempts to run them as tests.
-   
+
 """
 
 import os
                           default=env.get(env_opt),
                           help="Enable plugin %s: %s [%s]" %
                           (self.__class__.__name__, self.help(), env_opt))
-    
+
     def wantFile(self, file):
         """Override to return True for all files ending with .py"""
         # always want .py files
         if file.endswith('.py'):
             return True
-    
+
     def wantModule(self, module):
         """Override return True for all modules"""
         return True

File nose/plugins/attrib.py

View file
  • Ignore whitespace
 """Attribute selector plugin.
 
-Oftentimes when testing you will want to select tests based on criteria 
-rather then simply by filename.  For example, you might want to run 
-all tests except for the slow ones.  You can do this with the Attribute selector 
-plugin by setting attributes on your test methods.  Here is an example:
+Oftentimes when testing you will want to select tests based on
+criteria rather then simply by filename.  For example, you might want
+to run all tests except for the slow ones.  You can do this with the
+Attribute selector plugin by setting attributes on your test methods.
+Here is an example:
 
 .. code-block:: python
 
     def test_big_download():
         import urllib
         # commence slowness...
-    
+
     test_big_download.slow = 1
 
-Once you've assigned an attribute ``slow = 1`` you can exclude that 
+Once you've assigned an attribute ``slow = 1`` you can exclude that
 test and all other tests having the slow attribute by running ::
-    
+
     $ nosetests -a '!slow'
 
-There is also a decorator available for you that will set attributes.  
+There is also a decorator available for you that will set attributes.
 Here's how to set ``slow=1`` like above with the decorator:
 
 .. code-block:: python
         # commence slowness...
 
 This test could be run with ::
-    
+
     $ nosetests -a speed=slow
 
 Below is a reference to the different syntaxes available.
 
-Simple syntax 
+Simple syntax
 -------------
 
 Examples of using the ``-a`` and ``--attr`` options:
 
 * ``nosetests -a priority=2 -a slow``
    Runs tests that match either attribute
-    
+
 * ``nosetests -a tags=http``
-   If a test's ``tags`` attribute was a list and it contained the value 
+   If a test's ``tags`` attribute was a list and it contained the value
    ``http`` then it would be run
 
 * ``nosetests -a slow``
    (False, [], "", etc...)
 
 * ``nosetests -a '!slow'``
-   Runs tests that do NOT have the attribute ``slow`` or have a ``slow`` attribute 
-   that is equal to False
-   **NOTE**: 
-   if your shell (like bash) interprets '!' as a special character make sure to 
+   Runs tests that do NOT have the attribute ``slow`` or have a ``slow``
+   attribute that is equal to False
+   **NOTE**:
+   if your shell (like bash) interprets '!' as a special character make sure to
    put single quotes around it.
 
 Expression Evaluation
 compat_24 = sys.version_info >= (2, 4)
 
 def attr(*args, **kwargs):
-    """Decorator that adds attributes to objects 
+    """Decorator that adds attributes to objects
     for use with the Attribute (-a) plugin.
     """
     def wrap(func):
     """Returns default values for dictionary lookups."""
     def __init__(self, obj):
         self.obj = obj
-        
+
     def __getitem__(self, name):
         return self.obj.get(name, False)
 
 
 class AttributeGetter:
     """Helper for looking up attributes
-    
+
     First we check the method, and if the attribute is not present,
     we check the method's class.
     """
     def __init__(self):
         Plugin.__init__(self)
         self.attribs = []
-    
+
     def options(self, parser, env):
         """Register command line options"""
         parser.add_option("-a", "--attr",
                           dest="attr", action="append",
                           default=env.get('NOSE_ATTR'),
+                          metavar="ATTR",
                           help="Run only tests that have attributes "
                           "specified by ATTR [NOSE_ATTR]")
         # disable in < 2.4: eval can't take needed args
         match.
         """
         self.attribs = []
-        
+
         # handle python eval-expression parameter
         if compat_24 and options.eval_attr:
             eval_attr = tolist(options.eval_attr)
                 self.attribs.append(attr_group)
         if self.attribs:
             self.enabled = True
-            
+
     def validateAttrib(self, attribs):
         # TODO: is there a need for case-sensitive value comparison?
         # within each group, all must match for the group to match
                         break
                 elif type(obj_value) in (list, tuple):
                     # value must be found in the list attribute
-                    
+
                     if not str(value).lower() in [str(x).lower()
                                                   for x in obj_value]:
                         match = False
         if wanted:
             return None
         return False
-        
+
     def wantFunction(self, function):
         """Accept the function if its attributes match.
         """
         return self.validateAttrib(function.__dict__)
-        
+
     def wantMethod(self, method):
         """Accept the method if its attributes match.
         """

File nose/plugins/base.py

View file
  • Ignore whitespace
             self.name = self.__class__.__name__.lower()
         if self.enableOpt is None:
             self.enableOpt = "enable_plugin_%s" % self.name.replace('-', '_')
-            
+
     def addOptions(self, parser, env=None):
         """Add command-line options for this plugin.
 
         plugin.
         """
         self.add_options(parser, env)
-        
+
     def add_options(self, parser, env=None):
         """Non-camel-case version of func name for backwards compatibility.
         """
                  "be disabled" % (self, e), RuntimeWarning)
             self.enabled = False
             self.can_configure = False
-            
+
     def options(self, parser, env):
         """New plugin API: override to just set options. Implement
         this method instead of addOptions or add_options for normal
             sys.exc_info() tuple
           capt : string
             Captured output, if any
-            
+
             .. Note:: DEPRECATED: this parameter will not be passed
         """
         pass
             .. Note:: DEPRECATED: this parameter will not be passed
           tb_info : string
             Introspected traceback info, if any
-           
+
             .. Note:: DEPRECATED: this parameter will not be passed
         """
         pass
           capt : string
             Captured output, if any.
 
-            .. Note:: DEPRECATED: this parameter will not be passed            
+            .. Note:: DEPRECATED: this parameter will not be passed
         """
         pass
     addSuccess.changed = True
             The name of the module
         """
         pass
-    afterImport._new = True        
+    afterImport._new = True
 
     def afterTest(self, test):
         """Called after the test has been run and the result recorded
             The name of the module found in file
         """
     beforeImport._new = True
-    
+
     def beforeTest(self, test):
         """Called before the test is run (before startTest).
-        
+
         :Parameters:
           test : :class:`nose.case.Test`
             the test case
-        """        
+        """
         pass
     beforeTest._new = True
-            
+ 
     def begin(self):
         """Called before any tests are collected or run. Use this to
         perform any setup needed before testing begins.
     def formatError(self, test, err):
         """Called in result.addError, before plugin.addError. If you
         want to replace or modify the error tuple, return a new error
-        tuple. 
+        tuple.
 
         :Parameters:
           test : :class:`nose.case.Test`
         """
         pass
     loadTestsFromModule.generative = True
-    
+
     def loadTestsFromName(self, name, module=None, importPath=None):
         """Return tests in this file or module. Return None if you are not able
         to load any tests, or an iterable if you are. May be a
             Module from which the name is to be loaded
           importPath :
             Path from which file (must be a python module) was found
-            
+
             .. Note:: DEPRECATED: this argument will NOT be passed.
         """
         pass
 
         .. Note:: This method replaces loadTestsFromPath from the 0.9
                   API.
-        
+
         :Parameters:
            filename : string
              The full path to the file or directory.
         """
         pass
     loadTestsFromPath.deprecated = True
-    
+
     def loadTestsFromTestCase(self, cls):
         """Return tests in this test case class. Return None if you are
         not able to load any tests, or an iterable if you are. May be a
         :Parameters:
           parser : :class:`ConfigParser`
             options parserinstance
-            
+
           env : dict
             environment, defaults to os.environ
         """

File nose/plugins/capture.py

View file
  • Ignore whitespace
     env_opt = 'NOSE_NOCAPTURE'
     name = 'capture'
     score = 500
-    
+
     def __init__(self):
         self.stdout = []
         self._buf = None
         """
         self.end()
         self._buf = None
-        
+
     def begin(self):
         """Replace sys.stdout with capture buffer.
         """
         """Flush capture buffer.
         """
         self.start()
-        
+
     def formatError(self, test, err):
         """Add captured output to error report.
         """
             # Don't return None as that will prevent other
             # formatters from formatting and remove earlier formatters
             # formats, instead return the err we got
-            return err 
+            return err
         ec, ev, tb = err
         return (ec, self.addCaptureToErr(ev, output), tb)
 

File nose/plugins/collect.py

View file
  • Ignore whitespace
 
 class CollectOnly(Plugin):
     """
-    Collect and output test names only, don't run any tests. 
+    Collect and output test names only, don't run any tests.
     """
     name = "collect-only"
     enableOpt = 'collect_only'
-    
+
     def options(self, parser, env):
         """Register commandline options.
         """
         # Disable context awareness
         log.debug("Preparing test loader")
         loader.suiteClass = TestSuiteFactory(self.conf)
-        
+
     def prepareTestCase(self, test):
         """Replace actual test with dummy that always passes.
         """

File nose/plugins/cover.py

View file
  • Ignore whitespace
         Plugin.options(self, parser, env)
         parser.add_option("--cover-package", action="append",
                           default=env.get('NOSE_COVER_PACKAGE'),
+                          metavar="PACKAGE",
                           dest="cover_packages",
                           help="Restrict coverage output to selected packages "
                           "[NOSE_COVER_PACKAGE]")

File nose/plugins/doctests.py

View file
  • Ignore whitespace
                           "not both. [NOSE_DOCTEST_TESTS]")
         parser.add_option('--doctest-extension', action="append",
                           dest="doctestExtension",
+                          metavar="EXT",
                           help="Also look for doctests in files with "
                           "this extension [NOSE_DOCTEST_EXTENSION]")
         parser.add_option('--doctest-result-variable',
                           dest='doctest_result_var',
                           default=env.get('NOSE_DOCTEST_RESULT_VAR'),
+                          metavar="VAR",
                           help="Change the variable name set to the result of "
                           "the last interpreter command from the default '_'. "
                           "Can be used to avoid conflicts with the _() "
                           "[NOSE_DOCTEST_RESULT_VAR]")
         parser.add_option('--doctest-fixtures', action="store",
                           dest="doctestFixtures",
+                          metavar="SUFFIX",
                           help="Find fixtures for a doctest file in module "
                           "with this name appended to the base name "
                           "of the doctest file")
             if not test.examples:
                 continue
             if not test.filename:
-                test.filename = module_file            
+                test.filename = module_file
             cases.append(DocTestCase(test, result_var=self.doctest_result_var))
         if cases:
             yield self.suiteClass(cases, context=module, can_split=False)
     provide an address() method that returns the correct address for
     the doctest case. To provide hints for address(), an obj may also
     be passed -- this will be used as the test object for purposes of
-    determining the test address, if it is provided.    
+    determining the test address, if it is provided.
     """
     def __init__(self, test, optionflags=0, setUp=None, tearDown=None,
                  checker=None, obj=None, result_var='_'):
         name = name.split('.')
         return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
     __str__ = __repr__
-                           
+
     def shortDescription(self):
         return 'Doctest: %s' % self.id()
 

File nose/plugins/logcapture.py

View file
  • Ignore whitespace
         parser.add_option(
             "--logging-format", action="store", dest="logcapture_format",
             default=env.get('NOSE_LOGFORMAT') or self.logformat,
+            metavar="FORMAT",
             help="Specify custom format to print statements. "
                  "Uses the same format as used by standard logging handlers."
                  " [NOSE_LOGFORMAT]")
         parser.add_option(
             "--logging-datefmt", action="store", dest="logcapture_datefmt",
             default=env.get('NOSE_LOGDATEFMT') or self.logdatefmt,
+            metavar="FORMAT",
             help="Specify custom date/time format to print statements. "
                  "Uses the same format as used by standard logging handlers."
                  " [NOSE_LOGDATEFMT]")
         parser.add_option(
             "--logging-filter", action="store", dest="logcapture_filters",
             default=env.get('NOSE_LOGFILTER'),
+            metavar="FILTER",
             help="Specify which statements to filter in/out. "
                  "By default everything is captured. If the output is too"
                  " verbose,\nuse this option to filter out needless output\n"

File nose/plugins/multiprocess.py

View file
  • Ignore whitespace
         parser.add_option("--processes", action="store",
                           default=env.get('NOSE_PROCESSES', 0),
                           dest="multiprocess_workers",
+                          metavar="NUM",
                           help="Spread test run among this many processes. "
                           "Set a number equal to the number of processors "
                           "or cores in your machine for best results. "
         parser.add_option("--process-timeout", action="store",
                           default=env.get('NOSE_PROCESS_TIMEOUT', 10),
                           dest="multiprocess_timeout",
+                          metavar="SECONDS",
                           help="Set timeout for return of results from each "
                           "test runner process. [NOSE_PROCESS_TIMEOUT]")
 

File nose/plugins/prof.py

View file
  • Ignore whitespace
         """
         if not self.available():
             return
-        Plugin.options(self, parser, env)                
+        Plugin.options(self, parser, env)
         parser.add_option('--profile-sort', action='store', dest='profile_sort',
                           default=env.get('NOSE_PROFILE_SORT', 'cumulative'),
+                          metavar="SORT",
                           help="Set sort order for profiler output")
         parser.add_option('--profile-stats-file', action='store',
                           dest='profile_stats_file',
+                          metavar="FILE",
                           default=env.get('NOSE_PROFILE_STATS_FILE'),
                           help='Profiler stats file; default is a new '
                           'temp file on each run')
         parser.add_option('--profile-restrict', action='append',
                           dest='profile_restrict',
+                          metavar="RESTRICT",
                           default=env.get('NOSE_PROFILE_RESTRICT'),
                           help="Restrict profiler output. See help for "
                           "pstats.Stats for details")

File nose/plugins/testid.py

View file
  • Ignore whitespace
         """
         Plugin.options(self, parser, env)
         parser.add_option('--id-file', action='store', dest='testIdFile',
-                          default='.noseids',
+                          default='.noseids', metavar="FILE",
                           help="Store test ids found in test runs in this "
                           "file. Default is the file .noseids in the "
                           "working directory.")

File nose/plugins/xunit.py

View file
  • Ignore whitespace
         Plugin.options(self, parser, env)
         parser.add_option(
             '--xunit-file', action='store',
-            dest='xunit_file',
+            dest='xunit_file', metavar="FILE",
             default=env.get('NOSE_XUNIT_FILE', 'nosetests.xml'),
             help=("Path to xml file to store the xunit report in. "
                   "Default is nosetests.xml in the working directory "