code: def test_allow_nan(self):
      for val in (float("inf"), float("-inf"), float("nan")):
          out = self.dumps([val])
          if val == val:  # inf
              self.assertEqual(self.loads(out), [val])
          else:  # nan
              res = self.loads(out)
              self.assertEqual(len(res), 1)
              self.assertNotEqual(res[0], res[0])
          msg = (
              f"Out of range float values are not JSON compliant: {val}"
          )
          self.assertRaisesRegex(
              ValueError, msg, self.dumps, [val], allow_nan=False
          )
  
file_path: cpython/Lib/test/test_json/test_float.py
imports: import math
  from test.test_json import PyTest, CTest
label_desc: Use image node_id 4 for calling the TestFloat obj's underlying member method code with example usage: obj.test_allow_nan() without return types