BUG? error retrieving argument of user-defined exception

Scott Lowrey slowrey at nextone.com
Thu Jan 8 17:32:05 UTC 2004


(Sorry if this is an inappropriate format but I want people to be able 
to just plug the test into their database and run it.)

The following exception test - using a builtin exception - works fine:

<?xml version="1.0"?>
<extension class="python.ExceptionTest" kind="test">
  <argument name="exception_class">
    <text>AssertionError</text>
  </argument>
  <argument name="exception_argument">
    <text>'this is the arg'</text>
  </argument>
  <argument name="source">
    <text>raise AssertionError('this is the arg')
</text>
  </argument>
  <argument name="prerequisites">
    <set/>
  </argument>
  <argument name="target_group">
    <text>.*</text>
  </argument>
  <argument name="resources">
    <set/>
  </argument>
</extension>

This one - using a user-defined exception - fails to find the exception 
value:

<?xml version="1.0"?>
<extension class="python.ExceptionTest" kind="test">
  <argument name="exception_class">
    <text>MyExc</text>
  </argument>
  <argument name="exception_argument">
    <text>'this is the arg'</text>
  </argument>
  <argument name="source">
    <text>class MyExc(Exception):
    def __init__(self, value):
        self.value = value
    def __str__(self):
        return repr(self.value)

raise MyExc('this is the arg')
</text>
  </argument>
  <argument name="prerequisites">
    <set/>
  </argument>
  <argument name="target_group">
    <text>.*</text>
  </argument>
  <argument name="resources">
    <set/>
  </argument>
</extension>

The error from QMTest is:

[slowrey at moondog tmp]$ qmtest run myexc.exc1
--- TEST RESULTS 
-------------------------------------------------------------

  myexc.exc1                                    : ERROR
    An exception occurred.

    qmtest.exception:
      exceptions.AttributeError: MyExc instance has no attribute 'args'

    qmtest.target:
      local

    qmtest.traceback:

        File "/opt/test/lib/qm/test/target.py", line 215, in RunTest
          descriptor.Run(context, result)

        File "/opt/test/lib/qm/test/database.py", line 246, in Run
          self._Execute(context, result, "Run")

        File "/opt/test/lib/qm/test/database.py", line 168, in _Execute
          eval("item.%s(context, result)" % method)

        File "", line 0, in ?

        File "/opt/test/lib/qm/test/classes/python.py", line 164, in Run
          self.CheckArgument(exc_info, result)

        File "/opt/test/lib/qm/test/classes/python.py", line 245, in 
CheckArgument
          argument = exc_info[1].args



-- 
*Scott Lowrey*
NexTone Communications
Germantown, Maryland

/(240)912-1369/
www.nextone.com <http://www.nextone.com>



More information about the qmtest mailing list