Example #1
0
 def test_warn(self):
     module = 'iris.fileformats.grib._load_convert'
     self.patch(module + '.options.warn_on_unsupported', True)
     generating_process(None)
     got_msgs = [call[0][0] for call in self.warn_patch.call_args_list]
     expected_msgs = ['Unable to translate type of generating process',
                      'Unable to translate background generating process',
                      'Unable to translate forecast generating process']
     for expect_msg in expected_msgs:
         matches = [msg for msg in got_msgs if expect_msg in msg]
         self.assertEqual(len(matches), 1)
         got_msgs.remove(matches[0])
 def test_warn(self):
     module = 'iris.fileformats.grib._load_convert'
     self.patch(module + '.options.warn_on_unsupported', True)
     generating_process(None)
     got_msgs = [call[0][0] for call in self.warn_patch.call_args_list]
     expected_msgs = [
         'Unable to translate type of generating process',
         'Unable to translate background generating process',
         'Unable to translate forecast generating process'
     ]
     for expect_msg in expected_msgs:
         matches = [msg for msg in got_msgs if expect_msg in msg]
         self.assertEqual(len(matches), 1)
         got_msgs.remove(matches[0])
Example #3
0
 def _check_warnings(self, with_forecast=True):
     module = 'iris.fileformats.grib._load_convert'
     self.patch(module + '.options.warn_on_unsupported', True)
     call_args = [None]
     call_kwargs = {}
     expected_fragments = [
         'Unable to translate type of generating process',
         'Unable to translate background generating process']
     if with_forecast:
         expected_fragments.append(
             'Unable to translate forecast generating process')
     else:
         call_kwargs['include_forecast_process'] = False
     generating_process(*call_args, **call_kwargs)
     got_msgs = [call[0][0] for call in self.warn_patch.call_args_list]
     for got_msg, expected_fragment in zip(sorted(got_msgs),
                                           sorted(expected_fragments)):
         self.assertIn(expected_fragment, got_msg)
Example #4
0
 def _check_warnings(self, with_forecast=True):
     module = 'iris.fileformats.grib._load_convert'
     self.patch(module + '.options.warn_on_unsupported', True)
     call_args = [None]
     call_kwargs = {}
     expected_fragments = [
         'Unable to translate type of generating process',
         'Unable to translate background generating process'
     ]
     if with_forecast:
         expected_fragments.append(
             'Unable to translate forecast generating process')
     else:
         call_kwargs['include_forecast_process'] = False
     generating_process(*call_args, **call_kwargs)
     got_msgs = [call[0][0] for call in self.warn_patch.call_args_list]
     for got_msg, expected_fragment in zip(sorted(got_msgs),
                                           sorted(expected_fragments)):
         self.assertIn(expected_fragment, got_msg)
Example #5
0
 def test_nowarn(self):
     generating_process(None)
     self.assertEqual(self.warn_patch.call_count, 0)
 def test_nowarn(self):
     generating_process(None)
     self.assertEqual(self.warn_patch.call_count, 0)