code: def test_realasdouble(self):
      # Test PyComplex_RealAsDouble()
      realasdouble = _testcapi.complex_realasdouble
  
      self.assertEqual(realasdouble(1 + 2j), 1.0)
      self.assertEqual(realasdouble(-1 + 0j), -1.0)
      self.assertEqual(realasdouble(4.25), 4.25)
      self.assertEqual(realasdouble(-1.0), -1.0)
      self.assertEqual(realasdouble(42), 42.0)
      self.assertEqual(realasdouble(-1), -1.0)
  
      # Test subclasses of complex/float
      self.assertEqual(realasdouble(ComplexSubclass(1 + 2j)), 1.0)
      self.assertEqual(realasdouble(FloatSubclass(4.25)), 4.25)
  
      # Test types with __complex__ dunder method
      self.assertEqual(realasdouble(Complex()), 4.25)
      self.assertRaises(TypeError, realasdouble, BadComplex())
      with self.assertWarns(DeprecationWarning):
          self.assertEqual(realasdouble(BadComplex2()), 4.25)
      with warnings.catch_warnings():
          warnings.simplefilter("error", DeprecationWarning)
          self.assertRaises(
              DeprecationWarning, realasdouble, BadComplex2()
          )
      self.assertRaises(RuntimeError, realasdouble, BadComplex3())
  
      # Test types with __float__ dunder method
      self.assertEqual(realasdouble(Float()), 4.25)
      self.assertRaises(TypeError, realasdouble, BadFloat())
      with self.assertWarns(DeprecationWarning):
          self.assertEqual(realasdouble(BadFloat2()), 4.25)
  
      self.assertRaises(TypeError, realasdouble, object())
  
imports: from math import isnan
  import errno
  import unittest
  import warnings
  from test.test_capi.test_getargs import BadComplex, BadComplex2, Complex, FloatSubclass, Float, BadFloat, BadFloat2, ComplexSubclass
  from test.support import import_helper
label_desc: Use image node_id 5 for calling the CAPIComplexTest obj's underlying member method code with example usage: obj.test_realasdouble() without return types