[Python-ideas] PEP 485: A Function for testing approximate equality

Guido van Rossum guido at python.org
Fri Feb 6 01:25:20 CET 2015


On Thu, Feb 5, 2015 at 4:11 PM, Chris Barker <chris.barker at noaa.gov> wrote:

>
> On Thu, Feb 5, 2015 at 2:49 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
>>
>> >- For unittests are you proposing to replace assertAlmostEquals or
>> deprecate that and add a new assertIsCloseTo? (I hope the latter.
>> >
>>
>> >Add an assertIsCloseTo -- whether assertAlmostEquals should be
>> deprecated I have no opinion on. Though it is useful, as it acts over a
>> sequence -- I"m guessing fols will want to keep it.
>>
>> Why not have assertIsCloseTo act over a sequence in exactly the same way
>> as assertAlmostEquals, in which case there's no reason to keep the latter
>> (except for existing unit tests that already use it, but presumably a long
>> period of deprecation is sufficient there)?
>>
>
> Because assertAlmostEquals() is an absolute tolerance test -- not a
> relative one -- and it lets (encourages?) users to specify number of
> decimal places (or optionally install a explicit absolute tolerance). I
> assume this is all there because someone found it useful.
>
> Again, I have little opinion about all this -- I don't like/use unitest
> anyway. I"m hoping someone else will take up the mantle of what to do with
> unittest...
>

OK, let's just drop the idea of adding anything to unittest/case.py from
the PEP. People can just write self.assertTrue(math.isclose(...)). Or if
they're using py.test they can write assert math.isclose(...).

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150205/40b19c7e/attachment-0001.html>


More information about the Python-ideas mailing list