code: def test_Opener_various():
      # Check we can do all sorts of files here
      message = b"Oh what a giveaway"
      bz2_fileno = hasattr(BZ2File, "fileno")
      if HAVE_INDEXED_GZIP:
          import indexed_gzip as igzip
      with InTemporaryDirectory():
          sobj = BytesIO()
          files_to_test = [
              "test.txt",
              "test.txt.gz",
              "test.txt.bz2",
              sobj,
          ]
          if HAVE_ZSTD:
              files_to_test += ["test.txt.zst"]
          for input in files_to_test:
              with Opener(input, "wb") as fobj:
                  fobj.write(message)
                  assert fobj.tell() == len(message)
              if input == sobj:
                  input.seek(0)
              with Opener(input, "rb") as fobj:
                  message_back = fobj.read()
                  assert message == message_back
                  if input == sobj:
                      # Fileno is unsupported for BytesIO
                      with pytest.raises(UnsupportedOperation):
                          fobj.fileno()
                  elif input.endswith(".bz2") and not bz2_fileno:
                      with pytest.raises(AttributeError):
                          fobj.fileno()
                  # indexed gzip is used by default, and drops file
                  # handles by default, so we don't have a fileno.
                  elif (
                      input.endswith("gz")
                      and HAVE_INDEXED_GZIP
                      and Version(igzip.__version__) >= Version("0.7.0")
                  ):
                      with pytest.raises(igzip.NoHandleError):
                          fobj.fileno()
                  else:
                      # Just check there is a fileno
                      assert fobj.fileno() != 0
  
imports: import contextlib
  import hashlib
  import os
  import time
  import unittest
  from gzip import GzipFile
  from io import BytesIO, UnsupportedOperation
  from unittest import mock
  import pytest
  from packaging.version import Version
  from ..deprecator import ExpiredDeprecationError
  from ..openers import HAVE_INDEXED_GZIP, BZ2File, DeterministicGzipFile, ImageOpener, Opener
  from ..optpkg import optional_package
  from ..tmpdirs import InTemporaryDirectory
label_desc: Use image node_id 2 for calling a global function with example usage: test_Opener_various() without return types