code: def test_format_manager(test_images, tmp_path):
      """Test working of the format manager"""
  
      formats = imageio.formats
  
      # Test basics of FormatManager
      assert isinstance(formats, FormatManager)
      assert len(formats) > 0
      assert "FormatManager" in repr(formats)
  
      # Get docs
      smalldocs = str(formats)
      # fulldocs = formats.create_docs_for_all_formats()
  
      # Check each format ...
      for format in formats:
          #  That each format is indeed a Format
          assert isinstance(format, Format)
          # That they are mentioned
          assert format.name in smalldocs
          # assert format.name in fulldocs
  
      fname = test_images / "chelsea.png"
      fname2 = tmp_path / "chelsea.noext"
      shutil.copy(fname, fname2)
  
      # Check getting
      F1 = formats["PNG"]
      F2 = formats[".png"]
      F3 = formats[fname2.as_posix()]  # will look in file itself
      assert type(F1) is type(F2)
      assert type(F1) is type(F3)
      # Check getting
      F1 = formats["DICOM"]
      F2 = formats[".dcm"]
      F3 = formats[
          "dcm"
      ]  # If omitting dot, format is smart enough to try with
      assert type(F1) is type(F2)
      assert type(F1) is type(F3)
      # Fail
      raises(ValueError, formats.__getitem__, 678)  # must be str
      raises(IndexError, formats.__getitem__, ".nonexistentformat")
  
      # Adding a format
      myformat = Format("test", "test description", "testext1 testext2")
      formats.add_format(myformat)
      assert type(myformat) in [type(f) for f in formats]
      assert type(formats["testext1"]) is type(myformat)
      assert type(formats["testext2"]) is type(myformat)
      # Fail
      raises(ValueError, formats.add_format, 678)  # must be Format
      raises(
          ValueError, formats.add_format, myformat
      )  # cannot add twice
  
      # Adding a format with the same name
      myformat2 = Format("test", "other description", "foo bar")
      raises(ValueError, formats.add_format, myformat2)  # same name
      formats.add_format(myformat2, True)  # overwrite
      assert formats["test"].name is not myformat.name
      assert type(formats["test"]) is type(myformat2)
  
      # Test show (we assume it shows correctly)
      formats.show()
  
imports: import gc
  import shutil
  from pathlib import Path
  import sys
  from typing import List
  import imageio
  import imageio
  import numpy
  import pytest
  from imageio.core import Format, FormatManager, Request
  from pytest import raises
  from conftest import deprecated_test
label_desc: Use image node_id 5 for calling a global function with example usage: test_format_manager(test_images, tmp_path) without return types