From 832d65857176f727a22c9d3f265db5f0159880c6 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 1 Nov 2014 13:07:10 -0700 Subject: [PATCH] Use assertAlmostEqual (#1054) Rounding and then comparing could lead to some surprising sensitivity. This uses a known-good approximate comparison. --- test/test_importadded.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_importadded.py b/test/test_importadded.py index 22a795398..6a885cd71 100644 --- a/test/test_importadded.py +++ b/test/test_importadded.py @@ -74,8 +74,7 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): def assertEqualTimes(self, first, second, msg=None): """For comparing file modification times at a sufficient precision""" - assert round(first, 4) == round(second, 4), \ - "{:f} != {:f}{}".format(first, second, ": " + msg if msg else "") + self.assertAlmostEqual(first, second, places=4, msg=msg) def test_import_album_with_added_dates(self): self.importer.run()