code: def test_exception_swallow(self):
      # bug #262: __exit__ calls cur.close() that hides the exception
      # with another error.
      try:
          with self.conn as conn:
              with conn.cursor("named") as cur:
                  cur.execute("select 1/0")
                  cur.fetchone()
      except psycopg2.DataError as e:
          self.assertEqual(e.pgcode, "22012")
      else:
          self.fail("where is my exception?")
  
imports: import psycopg2
  import psycopg2.extensions
  import unittest
  from .testutils import ConnectingTestCase, skip_before_postgres, skip_if_crdb
label_desc: Use image node_id 4 for calling the WithCursorTestCase obj's underlying member method code with example usage: obj.test_exception_swallow() without return types