def test_load_file_with_captured_warnings(self): test_filename = tests.get_data_path(('NetCDF', 'testing', 'units.nc')) with warnings.catch_warnings(record=True) as filtered_warnings: with suppress_unit_warnings(): iris.load(test_filename) filtered_warnings_list = [str(w.message) for w in filtered_warnings] self.assertEqual(len(filtered_warnings_list), 0)
def test_load_file_with_captured_warnings(self): test_filename = tests.get_data_path(('NetCDF', 'testing', 'units.nc')) with warnings.catch_warnings(record=True) as filtered_warnings: with suppress_unit_warnings(): iris.load(test_filename) filtered_warnings_list = [w.message.message for w in filtered_warnings] self.assertEqual(len(filtered_warnings_list), 0)
def test_generic_warnings(self): unit_warning = ("Ignoring netCDF variable 'AL' invalid " "units '(0 - 1)'") example_warning = 'Example warning' with warnings.catch_warnings(record=True) as filtered_warnings: with suppress_unit_warnings(): warnings.warn(unit_warning) warnings.warn(example_warning) # Get to the actual warning strings for testing purposes. filtered_warnings_list = [str(w.message) for w in filtered_warnings] self.assertNotIn(unit_warning, filtered_warnings_list) self.assertIn(example_warning, filtered_warnings_list)
def test_generic_warnings(self): unit_warning = ("Ignoring netCDF variable 'AL' invalid " "units '(0 - 1)'") example_warning = 'Example warning' with warnings.catch_warnings(record=True) as filtered_warnings: with suppress_unit_warnings(): warnings.warn(unit_warning) warnings.warn(example_warning) # Get to the actual warning strings for testing purposes. filtered_warnings_list = [w.message.message for w in filtered_warnings] self.assertNotIn(unit_warning, filtered_warnings_list) self.assertIn(example_warning, filtered_warnings_list)