[Python-Dev] Proposed unittest changes
Michael Foord
fuzzyman at voidspace.org.uk
Thu Apr 17 18:11:32 CEST 2008
Christian Heimes wrote:
> Michael Foord schrieb:
>
>> By etc I assume you mean:
>>
>> assertLessThan
>> assertGreaterThan
>> assertLessThanOrEquals
>> assertGreaterThanOrEquals
>>
>> Would not variants be useful as well - it seems not as the not of one is
>> always another... (I think 'assertLessThan' reads better than
>> 'assertLess' but will do what I'm told...)
>>
>
> Most of the etc. could be simplified with a function assertOp which
> takes an operator as first argument
>
> import operator
> def assertOp(self, op, a, b, msg):
> func = getattr(operator, op)
> self.assert_(func(a, b) ...)
>
> assertOp("gt", a, b) == assert a > g
>
>
Which choice would be up to consensus.
I'm agnostic on this one.
> I also like to have some assert for is, type, isinstance, issubclass and
> contains.
>
>
is and contains ('in') I listed. type, isinstance, issubclass would be
extra.
Michael
> Christian
>
More information about the Python-Dev
mailing list