def test_log_level(self): """Test the `log_level` function.""" original = self.__class__.original # original to module i.e. default self.assertEqual(original, "WARNING") # test default cfdm.LOG_LEVEL(original) # reset from setUp() value to avoid coupling # Now test getting and setting for all valid values in turn, # where use fact that setting returns old value hence set # value on next call: previous = cfdm.log_level() for value in self.valid_log_values_ci: self.assertEqual(cfdm.LOG_LEVEL(value), previous) previous = cfdm.LOG_LEVEL() # update previous value # Some conversions to equivalent, standardised return value: if isinstance(value, int) and cfdm._is_valid_log_level_int( value ): # str from LOG_LEVEL value = cfdm.constants.ValidLogLevels(value).name # convert if isinstance(value, str): # LOG_LEVEL returns all caps string value = value.upper() self.assertEqual(previous, value) with self.assertRaises(ValueError): cfdm.log_level(4) cfdm.LOG_LEVEL(4) # check alias too with self.assertRaises(ValueError): cfdm.log_level("ERROR") # notable as is valid Python logging level cfdm.LOG_LEVEL("ERROR")
def setUp(self): """Preparations called immediately before each test method.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE") # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: cfdm.LOG_LEVEL('DEBUG') # # < ... test code ... > # cfdm.log_level('DISABLE') self.filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "test_file.nc") self.string_filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "string_char.nc") self.netcdf3_fmts = [ "NETCDF3_CLASSIC", "NETCDF3_64BIT", "NETCDF3_64BIT_OFFSET", "NETCDF3_64BIT_DATA", ] self.netcdf4_fmts = [ "NETCDF4", "NETCDF4_CLASSIC", ] self.netcdf_fmts = self.netcdf3_fmts + self.netcdf4_fmts
def setUp(self): # Disable log messages to silence expected warnings cfdm.LOG_LEVEL('DISABLE') # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: # # cfdm.LOG_LEVEL('DEBUG') # < ... test code ... > # cfdm.log_level('DISABLE') self.filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'test_file_b.nc')
def setUp(self): """Preparations called immediately before each test method.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE") # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: # # cfdm.LOG_LEVEL('DEBUG') # < ... test code ... > # cfdm.log_level('DISABLE') self.filename = os.path.join( os.path.dirname(os.path.abspath(__file__)), "test_file.nc") f = cfdm.read(self.filename) self.assertEqual(len(f), 1, f"f={f!r}") self.f = f[0]
def setUp(self): """Preparations called immediately before each test method.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE") # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: # # cfdm.LOG_LEVEL('DEBUG') # < ... test code ... > # cfdm.log_level('DISABLE') dataset_dir = os.path.dirname(os.path.abspath(__file__)) self.parent_file = os.path.join(dataset_dir, "parent.nc") self.external_file = os.path.join(dataset_dir, "external.nc") self.combined_file = os.path.join(dataset_dir, "combined.nc") self.external_missing_file = os.path.join(dataset_dir, "external_missing.nc")
def setUp(self): """Preparations called immediately before each test method.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE") # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: # cfdm.LOG_LEVEL('DEBUG') # < ... test code ... > # cfdm.LOG_LEVEL('DISABLE') self.geometry_interior_ring_file = os.path.join( os.path.dirname(os.path.abspath(__file__)), "geometry_interior_ring.nc", ) self.geometry_interior_ring_file_2 = os.path.join( os.path.dirname(os.path.abspath(__file__)), "geometry_interior_ring_2.nc", )
def setUp(self): # Disable log messages to silence expected warnings cfdm.LOG_LEVEL('DISABLE') # Note: to enable all messages for given methods, lines or # calls (those without a 'verbose' option to do the same) # e.g. to debug them, wrap them (for methods, start-to-end # internally) as follows: # # cfdm.LOG_LEVEL('DEBUG') # < ... test code ... > # cfdm.log_level('DISABLE') dir_with_data_files = os.path.dirname(os.path.realpath(__file__)) dataset_dir = os.path.dirname(os.path.abspath(__file__)) self.parent_file = os.path.join(dataset_dir, 'parent.nc') self.external_file = os.path.join(dataset_dir, 'external.nc') self.combined_file = os.path.join(dataset_dir, 'combined.nc') self.external_missing_file = os.path.join(dataset_dir, 'external_missing.nc') self.test_only = []
def setUp(self): """TODO DOCS.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE")
def setUp(self): # Disable log messages to silence expected warnings cfdm.LOG_LEVEL('DISABLE')
def setUp(self): """Preparations called immediately before each test method.""" # Disable log messages to silence expected warnings cfdm.LOG_LEVEL("DISABLE")