
On 29 January 2015 at 13:34, Steven D'Aprano <steve@pearwood.info> wrote:
For testing, I think it needs to be a TestCase.assert* method. Otherwise you have people writing
self.assertTrue(close_enough(a, b))
The only downside is that this doesn't consider other test frameworks like nose and py.test. For those frameworks, you need a standalone function. *If* the intention is to expose a function that people can use for testing, I think it needs to be a standalone close_enough function plus a unittest assert method that uses that function. But I'm fairly sure by now that Guido's right and this should just be a recipe. I can write my own close_enough function now, with the information from this thread. The only bit I'd struggle over is what tolerance to use, and it doesn't look like anyone has a particularly good universal answer for that :-) Paul