code: def test_open_formats(self):
      PNGFILE = "Tests/images/hopper.png"
      JPGFILE = "Tests/images/hopper.jpg"
  
      with pytest.raises(TypeError):
          with Image.open(PNGFILE, formats=123):
              pass
  
      for formats in [
          ["JPEG"],
          ("JPEG",),
          ["jpeg"],
          ["Jpeg"],
          ["jPeG"],
          ["JpEg"],
      ]:
          with pytest.raises(UnidentifiedImageError):
              with Image.open(PNGFILE, formats=formats):
                  pass
  
          with Image.open(JPGFILE, formats=formats) as im:
              assert im.mode == "RGB"
              assert im.size == (128, 128)
  
      for file in [PNGFILE, JPGFILE]:
          with Image.open(file, formats=None) as im:
              assert im.mode == "RGB"
              assert im.size == (128, 128)
  
imports: import io
  import os
  import shutil
  import sys
  import tempfile
  import pytest
  from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError
  from .helper import assert_image_equal, assert_image_equal_tofile, assert_image_similar_tofile, assert_not_all_same, hopper, is_win32, mark_if_feature_version, skip_unless_feature
label_desc: Use image node_id 5 for calling the TestImage obj's underlying member method code with example usage: obj.test_open_formats() without return types