[qmtest] [PATCH] make "qmtest extension" list result streams

Mark Mitchell mark at codesourcery.com
Fri Feb 28 07:00:05 UTC 2003


On Thu, 2003-02-27 at 01:44, Vladimir Prus wrote:
> 
> Hi,
> I've noticed that "qmtest extensions" does not list result stream classes.
> The patch is really trivial:
> 
> Log: 
> Fix "qmtest extensions".
> 
> * qt/test/cmdline.py
>     (QMTest.__ExecuteExtensions): Use global 'extension_kinds' variable,
>       instead of duplicating the same list of kinds.

I committed this variant.  Thanks!

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
-------------- next part --------------
2003-02-27  Mark Mitchell  <mark at codesourcery.com>

	* qm/test/cmdline.py (_make_comma_separated_string): New
	function.
	(QMTest.commands_spec): Use it.
	(QMTest.__ExecuteExtensions): Use base.extension_kinds.
	(QMTest.__ExecuteRegister): Likewise.

Index: qm/test/cmdline.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/cmdline.py,v
retrieving revision 1.80
diff -c -5 -p -r1.80 cmdline.py
*** qm/test/cmdline.py	28 Feb 2003 06:17:12 -0000	1.80
--- qm/test/cmdline.py	28 Feb 2003 06:42:47 -0000
***************
*** 12,22 ****
  # For license terms see the file COPYING.
  #
  ########################################################################
  
  ########################################################################
! # imports
  ########################################################################
  
  from   __future__ import nested_scopes
  import base
  import database
--- 12,22 ----
  # For license terms see the file COPYING.
  #
  ########################################################################
  
  ########################################################################
! # Imports
  ########################################################################
  
  from   __future__ import nested_scopes
  import base
  import database
*************** import signal
*** 37,54 ****
  import string
  import sys
  import xml.sax
  
  ########################################################################
! # variables
  ########################################################################
  
  _the_qmtest = None
  """The global 'QMTest' object."""
  
  ########################################################################
! # classes
  ########################################################################
  
  class QMTest:
      """An instance of QMTest."""
  
--- 37,90 ----
  import string
  import sys
  import xml.sax
  
  ########################################################################
! # Variables
  ########################################################################
  
  _the_qmtest = None
  """The global 'QMTest' object."""
  
  ########################################################################
! # Functions
! ########################################################################
! 
! def _make_comma_separated_string (items, conjunction):
!     """Return a string consisting of the 'items', separated by commas.
! 
!     'items' -- A list of strings giving the items in the list.
! 
!     'conjunction' -- A string to use before the final item, if there is
!     more than one.
! 
!     returns -- A string consisting all of the 'items', separated by
!     commas, and with the 'conjunction' before the final item."""
!     
!     s = ""
!     need_comma = 0
!     # Go through almost all of the items, adding them to the
!     # comma-separated list.
!     for i in items[:-1]:
!         # Add a comma if this isn't the first item in the list.
!         if need_comma:
!             s += ", "
!         else:
!             need_comma = 1
!         # Add this item.
!         s += "'%s'" % i
!     # The last item is special, because we need to include the "or".
!     if items:
!         i = items[-1]
!         if need_comma:
!             s += ", %s " % conjunction
!         s += "'%s'" % i
! 
!     return s
!     
! ########################################################################
! # Classes
  ########################################################################
  
  class QMTest:
      """An instance of QMTest."""
  
*************** class QMTest:
*** 304,316 ****
           "",
           """
  List the available extension classes.
  
  Use the '--kind' option to limit the classes displayed to test classes,
! resource classes, etc.  The parameter to '--kind' can be one of 'test',
! 'resource', 'database', or 'target'.
!          """,
           (
             extension_kind_option_spec,
             help_option_spec,
           )
          ),
--- 340,351 ----
           "",
           """
  List the available extension classes.
  
  Use the '--kind' option to limit the classes displayed to test classes,
! resource classes, etc.  The parameter to '--kind' can be one of """  + \
!          _make_comma_separated_string(base.extension_kinds, "or") + "\n",
           (
             extension_kind_option_spec,
             help_option_spec,
           )
          ),
*************** resource classes, etc.  The parameter to
*** 325,336 ****
          ("register",
           "Register an extension class.",
           "KIND CLASS",
           """
  Register an extension class with QMTest.  KIND is the kind of extension
! class to register; it must be one of 'test', 'resource', 'database',
! or 'target'.
  
  The CLASS gives the name of the class in the form 'module.class'.
  
  QMTest will search the available extension class directories to find the
  new CLASS.  QMTest looks for files whose basename is the module name and
--- 360,371 ----
          ("register",
           "Register an extension class.",
           "KIND CLASS",
           """
  Register an extension class with QMTest.  KIND is the kind of extension
! class to register; it must be one of """ + \
!          _make_comma_separated_string(base.extension_kinds, "or") + """
  
  The CLASS gives the name of the class in the form 'module.class'.
  
  QMTest will search the available extension class directories to find the
  new CLASS.  QMTest looks for files whose basename is the module name and
*************** Valid formats are "full", "brief" (the d
*** 887,897 ****
              # command can be used without a database.
              database = None
  
          # Figure out what kinds of extensions we're going to list.
          kind = self.GetCommandOption("kind")
!         kinds = ['test', 'resource', 'database', 'target']
          if kind:
              if kind not in kinds:
                  raise qm.cmdline.CommandError, \
                        qm.error("invalid extension kind",
                                 kind = kind)
--- 922,932 ----
              # command can be used without a database.
              database = None
  
          # Figure out what kinds of extensions we're going to list.
          kind = self.GetCommandOption("kind")
!         kinds = base.extension_kinds
          if kind:
              if kind not in kinds:
                  raise qm.cmdline.CommandError, \
                        qm.error("invalid extension kind",
                                 kind = kind)
*************** Valid formats are "full", "brief" (the d
*** 930,940 ****
              return 1
          kind = self.__arguments[0]
          class_name = self.__arguments[1]
  
          # Check that the KIND is valid.
!         if kind not in ['test', 'resource', 'database', 'target']:
              raise qm.cmdline.CommandError, \
                    qm.error("invalid extension kind",
                             kind = kind)
  
          # Check that the CLASS_NAME is well-formed.
--- 965,975 ----
              return 1
          kind = self.__arguments[0]
          class_name = self.__arguments[1]
  
          # Check that the KIND is valid.
!         if kind not in base.extension_kinds:
              raise qm.cmdline.CommandError, \
                    qm.error("invalid extension kind",
                             kind = kind)
  
          # Check that the CLASS_NAME is well-formed.
*************** Valid formats are "full", "brief" (the d
*** 1474,1484 ****
          
          return test_names
  
                         
  ########################################################################
! # functions
  ########################################################################
  
  def get_qmtest():
      """Returns the global QMTest object.
  
--- 1509,1519 ----
          
          return test_names
  
                         
  ########################################################################
! # Functions
  ########################################################################
  
  def get_qmtest():
      """Returns the global QMTest object.
  


More information about the qmtest mailing list