code: def test_intconversion(self):
      # Test __int__()
      class ClassicMissingMethods:
          pass
  
      self.assertRaises(TypeError, int, ClassicMissingMethods())
  
      class MissingMethods(object):
          pass
  
      self.assertRaises(TypeError, int, MissingMethods())
  
      class Foo0:
          def __int__(self):
              return 42
  
      self.assertEqual(int(Foo0()), 42)
  
      class Classic:
          pass
  
      for base in (object, Classic):
  
          class IntOverridesTrunc(base):
              def __int__(self):
                  return 42
  
              def __trunc__(self):
                  return -12
  
          self.assertEqual(int(IntOverridesTrunc()), 42)
  
          class JustTrunc(base):
              def __trunc__(self):
                  return 42
  
          with self.assertWarns(DeprecationWarning):
              self.assertEqual(int(JustTrunc()), 42)
  
          class ExceptionalTrunc(base):
              def __trunc__(self):
                  1 / 0
  
          with self.assertRaises(ZeroDivisionError), self.assertWarns(
              DeprecationWarning
          ):
              int(ExceptionalTrunc())
  
          for trunc_result_base in (object, Classic):
  
              class Index(trunc_result_base):
                  def __index__(self):
                      return 42
  
              class TruncReturnsNonInt(base):
                  def __trunc__(self):
                      return Index()
  
              with self.assertWarns(DeprecationWarning):
                  self.assertEqual(int(TruncReturnsNonInt()), 42)
  
              class Intable(trunc_result_base):
                  def __int__(self):
                      return 42
  
              class TruncReturnsNonIndex(base):
                  def __trunc__(self):
                      return Intable()
  
              with self.assertWarns(DeprecationWarning):
                  self.assertEqual(int(TruncReturnsNonInt()), 42)
  
              class NonIntegral(trunc_result_base):
                  def __trunc__(self):
                      # Check that we avoid infinite recursion.
                      return NonIntegral()
  
              class TruncReturnsNonIntegral(base):
                  def __trunc__(self):
                      return NonIntegral()
  
              try:
                  with self.assertWarns(DeprecationWarning):
                      int(TruncReturnsNonIntegral())
              except TypeError as e:
                  self.assertEqual(
                      str(e),
                      "__trunc__ returned non-Integral"
                      " (type NonIntegral)",
                  )
              else:
                  self.fail(
                      "Failed to raise TypeError with %s"
                      % ((base, trunc_result_base),)
                  )
  
              # Regression test for bugs.python.org/issue16060.
              class BadInt(trunc_result_base):
                  def __int__(self):
                      return 42.0
  
              class TruncReturnsBadInt(base):
                  def __trunc__(self):
                      return BadInt()
  
              with self.assertRaises(TypeError), self.assertWarns(
                  DeprecationWarning
              ):
                  int(TruncReturnsBadInt())
  
imports: import sys
  import time
  import unittest
  from unittest import mock
  from test import support
  from test.test_grammar import VALID_UNDERSCORE_LITERALS, INVALID_UNDERSCORE_LITERALS
label_desc: Use image node_id 14 for calling the IntTestCases obj's underlying member method code with example usage: obj.test_intconversion() and returns: int, int, unknown, int, int, Index, int, Intable, NonIntegral, NonIntegral, int, BadInt