class_docstr: Test NetCDF4 File Handler Utility class.
class_docstr_tok: ["Test","NetCDF4","File","Handler","Utility","class","."]
docstr: Create a test NetCDF4 file.
docstr_tok: ["Create","a","test","NetCDF4","file","."]
code: def setUp(self):
      """Create a test NetCDF4 file."""
      from netCDF4 import Dataset
  
      with Dataset("test.nc", "w") as nc:
          # Create dimensions
          nc.createDimension("rows", 10)
          nc.createDimension("cols", 100)
  
          # Create Group
          g1 = nc.createGroup("test_group")
  
          # Add datasets
          ds1_f = g1.createVariable(
              "ds1_f", np.float32, dimensions=("rows", "cols")
          )
          ds1_f[:] = np.arange(10.0 * 100).reshape((10, 100))
          ds1_i = g1.createVariable(
              "ds1_i", np.int32, dimensions=("rows", "cols")
          )
          ds1_i[:] = np.arange(10 * 100).reshape((10, 100))
          ds2_f = nc.createVariable(
              "ds2_f", np.float32, dimensions=("rows", "cols")
          )
          ds2_f[:] = np.arange(10.0 * 100).reshape((10, 100))
          ds2_i = nc.createVariable(
              "ds2_i", np.int32, dimensions=("rows", "cols")
          )
          ds2_i[:] = np.arange(10 * 100).reshape((10, 100))
          ds2_s = nc.createVariable(
              "ds2_s", np.int8, dimensions=("rows",)
          )
          ds2_s[:] = np.arange(10)
          ds2_sc = nc.createVariable("ds2_sc", np.int8, dimensions=())
          ds2_sc[:] = 42
  
          # Add attributes
          nc.test_attr_str = "test_string"
          nc.test_attr_int = 0
          nc.test_attr_float = 1.2
          nc.test_attr_str_arr = np.array(b"test_string2")
          g1.test_attr_str = "test_string"
          g1.test_attr_int = 0
          g1.test_attr_float = 1.2
          for d in [ds1_f, ds1_i, ds2_f, ds2_i]:
              d.test_attr_str = "test_string"
              d.test_attr_int = 0
              d.test_attr_float = 1.2
  
imports: import os
  import unittest
  import numpy
  import pytest
label_desc: Use image node_id 1 for calling the TestNetCDF4FileHandler obj's underlying member method code with example usage: obj.setUp() without return types