[qmtest] patch: Various enhancements and fixes

Stefan Seefeld stefan at codesourcery.com
Fri Jun 2 22:13:36 UTC 2006


Mark Mitchell wrote:
> Stefan Seefeld wrote:

>> Index: qm/extension.py
>> ===================================================================
>> RCS file: /home/qm/Repository/qm/qm/extension.py,v
>> retrieving revision 1.20
>> diff -u -r1.20 extension.py
>> --- qm/extension.py	1 Dec 2005 08:27:12 -0000	1.20
>> +++ qm/extension.py	2 Jun 2006 12:54:48 -0000
>> @@ -151,7 +151,8 @@
>>          if __debug__:
>>              dictionary = get_class_arguments_as_dictionary(self.__class__)
>>              for a, v in arguments.items():
>> -                assert dictionary.has_key(a)
>> +                if not dictionary.has_key(a):
>> +                    raise AttributeError, a
> 
> What is the logic for this change?  We're in __debug__ so we know assert
> will work.  I'm fine with the change; I'm just curious as to the reason.

I was running some extension class that I passed a wrong attribute in its
constructor, and all I got was an assertion error, i.e. no information
about what the wrong attribute was. The above change was the only way
for me to see what I did wrong.

>> +    def GetStringList(self, key, default = None):
>> +        """Return the list of strings associated with 'key'.
>> +
>> +        'key' -- A string.
>> +
>> +        'default' -- A default list.
>> +
>> +        If there is no value associated with 'key' and default is not
>> +        'None', then the boolean value associated with default is
>> +        used.  
> 
> What do you mean "boolean value"?  It looks like you just return
> default.  It also seems like "[]" would be a better default.

Sorry, I was mindlessly c&p'ing (from 'GetBoolean()').
In fact, whenever 'default' is not None, it is returned if there
is no variable associated with 'key'. Thus, users who want to
provide an empty list as default value should call the function
as 'GetStringList(key, [])'.

Thanks,
		Stefan

-- 
Stefan Seefeld
CodeSourcery
stefan at codesourcery.com
(650) 331-3385 x718



More information about the qmtest mailing list