class_docstr: Test NetCDF4 File Handler Utility class.
class_docstr_tok: ["Test","NetCDF4","File","Handler","Utility","class","."]
docstr: Test that caching works as intended.
docstr_tok: ["Test","that","caching","works","as","intended","."]
code: def test_caching(self):
      """Test that caching works as intended."""
      from satpy.readers.netcdf_utils import NetCDF4FileHandler
  
      h = NetCDF4FileHandler(
          "test.nc", {}, {}, cache_var_size=1000, cache_handle=True
      )
      assert h.file_handle is not None
      assert h.file_handle.isopen()
  
      assert sorted(h.cached_file_content.keys()) == ["ds2_s", "ds2_sc"]
      # with caching, these tests access different lines than without
      np.testing.assert_array_equal(h["ds2_s"], np.arange(10))
      np.testing.assert_array_equal(
          h["test_group/ds1_i"], np.arange(10 * 100).reshape((10, 100))
      )
      # check that root variables can still be read from cached file object,
      # even if not cached themselves
      np.testing.assert_array_equal(
          h["ds2_f"], np.arange(10.0 * 100).reshape((10, 100))
      )
      h.__del__()
      assert not h.file_handle.isopen()
  
imports: import os
  import unittest
  import numpy
  import pytest
label_desc: Use image node_id 6 for calling the TestNetCDF4FileHandler obj's underlying member method code with example usage: obj.test_caching() without return types