From 42606ee47014a6fcd8f66f837eda8c3dfb4dd390 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Wed, 11 Nov 2020 10:05:23 +0100 Subject: [PATCH] Use assertAlmostEqual for float comparisons Use `assertAlmostEqual` for float comparisons in UJSON tests --- srsly/tests/ujson/test_ujson.py | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/srsly/tests/ujson/test_ujson.py b/srsly/tests/ujson/test_ujson.py index 795d371..c736bdf 100644 --- a/srsly/tests/ujson/test_ujson.py +++ b/srsly/tests/ujson/test_ujson.py @@ -752,25 +752,25 @@ def test_decodeArrayWithBigInt(self): self.assertRaises(ValueError, ujson.decode, input) def test_decodeFloatingPointAdditionalTests(self): - self.assertEqual(-1.1234567893, ujson.loads("-1.1234567893")) - self.assertEqual(-1.234567893, ujson.loads("-1.234567893")) - self.assertEqual(-1.34567893, ujson.loads("-1.34567893")) - self.assertEqual(-1.4567893, ujson.loads("-1.4567893")) - self.assertEqual(-1.567893, ujson.loads("-1.567893")) - self.assertEqual(-1.67893, ujson.loads("-1.67893")) - self.assertEqual(-1.7893, ujson.loads("-1.7893")) - self.assertEqual(-1.893, ujson.loads("-1.893")) - self.assertEqual(-1.3, ujson.loads("-1.3")) - - self.assertEqual(1.1234567893, ujson.loads("1.1234567893")) - self.assertEqual(1.234567893, ujson.loads("1.234567893")) - self.assertEqual(1.34567893, ujson.loads("1.34567893")) - self.assertEqual(1.4567893, ujson.loads("1.4567893")) - self.assertEqual(1.567893, ujson.loads("1.567893")) - self.assertEqual(1.67893, ujson.loads("1.67893")) - self.assertEqual(1.7893, ujson.loads("1.7893")) - self.assertEqual(1.893, ujson.loads("1.893")) - self.assertEqual(1.3, ujson.loads("1.3")) + self.assertAlmostEqual(-1.1234567893, ujson.loads("-1.1234567893")) + self.assertAlmostEqual(-1.234567893, ujson.loads("-1.234567893")) + self.assertAlmostEqual(-1.34567893, ujson.loads("-1.34567893")) + self.assertAlmostEqual(-1.4567893, ujson.loads("-1.4567893")) + self.assertAlmostEqual(-1.567893, ujson.loads("-1.567893")) + self.assertAlmostEqual(-1.67893, ujson.loads("-1.67893")) + self.assertAlmostEqual(-1.7894, ujson.loads("-1.7894")) + self.assertAlmostEqual(-1.893, ujson.loads("-1.893")) + self.assertAlmostEqual(-1.3, ujson.loads("-1.3")) + + self.assertAlmostEqual(1.1234567893, ujson.loads("1.1234567893")) + self.assertAlmostEqual(1.234567893, ujson.loads("1.234567893")) + self.assertAlmostEqual(1.34567893, ujson.loads("1.34567893")) + self.assertAlmostEqual(1.4567893, ujson.loads("1.4567893")) + self.assertAlmostEqual(1.567893, ujson.loads("1.567893")) + self.assertAlmostEqual(1.67893, ujson.loads("1.67893")) + self.assertAlmostEqual(1.7894, ujson.loads("1.7894")) + self.assertAlmostEqual(1.893, ujson.loads("1.893")) + self.assertAlmostEqual(1.3, ujson.loads("1.3")) def test_ReadBadObjectSyntax(self): input = '{"age", 44}'