diff options
Diffstat (limited to 'simplejson/tests/test_float.py')
-rw-r--r-- | simplejson/tests/test_float.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/simplejson/tests/test_float.py b/simplejson/tests/test_float.py index f61ed68..e382ec2 100644 --- a/simplejson/tests/test_float.py +++ b/simplejson/tests/test_float.py @@ -5,13 +5,21 @@ import simplejson as json from simplejson.decoder import NaN, PosInf, NegInf class TestFloat(TestCase): - def test_degenerates(self): + def test_degenerates_allow(self): for inf in (PosInf, NegInf): self.assertEqual(json.loads(json.dumps(inf)), inf) # Python 2.5 doesn't have math.isnan nan = json.loads(json.dumps(NaN)) self.assertTrue((0 + nan) != nan) + def test_degenerates_ignore(self): + for f in (PosInf, NegInf, NaN): + self.assertEqual(json.loads(json.dumps(f, ignore_nan=True)), None) + + def test_degenerates_deny(self): + for f in (PosInf, NegInf, NaN): + self.assertRaises(ValueError, json.dumps, f, allow_nan=False) + def test_floats(self): for num in [1617161771.7650001, math.pi, math.pi**100, math.pi**-100, 3.1]: |