示例#1
0
 def test_valid_clip_latitudes(self):
     future = Future()
     new_value = not future.clip_latitudes
     msg = "'Future' property 'clip_latitudes' is deprecated"
     with self.assertWarnsRegexp(msg):
         future.clip_latitudes = new_value
     self.assertEqual(future.clip_latitudes, new_value)
示例#2
0
 def test_valid_clip_latitudes(self):
     future = Future()
     new_value = not future.clip_latitudes
     msg = "'Future' property 'clip_latitudes' is deprecated"
     with self.assertWarnsRegexp(msg):
         future.clip_latitudes = new_value
     self.assertEqual(future.clip_latitudes, new_value)
示例#3
0
 def test_invalid_arg(self):
     future = Future()
     with self.assertRaises(AttributeError):
         with future.context(this_does_not_exist=True):
             # Don't need to do anything here... the context manager
             # will (assuming it's working!) have already raised the
             # exception we're looking for.
             pass
示例#4
0
 def test_no_args(self):
     future = Future(cell_datetime_objects=False)
     self.assertFalse(future.cell_datetime_objects)
     with future.context():
         self.assertFalse(future.cell_datetime_objects)
         future.cell_datetime_objects = True
         self.assertTrue(future.cell_datetime_objects)
     self.assertFalse(future.cell_datetime_objects)
示例#5
0
 def test_invalid_arg(self):
     future = Future()
     with self.assertRaises(AttributeError):
         with future.context(this_does_not_exist=True):
             # Don't need to do anything here... the context manager
             # will (assuming it's working!) have already raised the
             # exception we're looking for.
             pass
示例#6
0
 def test_cell_datetime_objects(self):
     future = Future()
     new_value = not future.cell_datetime_objects
     with warnings.catch_warnings(record=True) as warn:
         warnings.simplefilter('always')
         future.cell_datetime_objects = new_value
     self.assertEqual(future.cell_datetime_objects, new_value)
     exp_wmsg = "'Future' property 'cell_datetime_objects' is deprecated"
     six.assertRegex(self, str(warn[0]), exp_wmsg)
示例#7
0
 def test_cell_datetime_objects(self):
     future = Future()
     new_value = not future.cell_datetime_objects
     with warnings.catch_warnings(record=True) as warn:
         warnings.simplefilter('always')
         future.cell_datetime_objects = new_value
     self.assertEqual(future.cell_datetime_objects, new_value)
     exp_wmsg = "'Future' property 'cell_datetime_objects' is deprecated"
     six.assertRegex(self, str(warn[0]), exp_wmsg)
示例#8
0
def patched_future(value=True, error=False):
    # This ensures that there exists a flag in Future to test against.
    future = Future()
    future.__dict__['example_future_flag'] = value
    if error:
        future.deprecated_options['example_future_flag'] = 'error'
    else:
        future.deprecated_options['example_future_flag'] = 'warning'
    return future
示例#9
0
 def test_with_arg(self):
     # Catch the deprecation when explicitly setting `cell_datetime_objects`
     # as the test is still useful even though the Future property is
     # deprecated.
     with warnings.catch_warnings():
         warnings.simplefilter('ignore')
         future = Future(cell_datetime_objects=False)
         self.assertFalse(future.cell_datetime_objects)
         with future.context(cell_datetime_objects=True):
             self.assertTrue(future.cell_datetime_objects)
         self.assertFalse(future.cell_datetime_objects)
示例#10
0
 def test_with_arg(self):
     # Catch the deprecation when explicitly setting `cell_datetime_objects`
     # as the test is still useful even though the Future property is
     # deprecated.
     with warnings.catch_warnings():
         warnings.simplefilter('ignore')
         future = Future(cell_datetime_objects=False)
         self.assertFalse(future.cell_datetime_objects)
         with future.context(cell_datetime_objects=True):
             self.assertTrue(future.cell_datetime_objects)
         self.assertFalse(future.cell_datetime_objects)
示例#11
0
    def test_exception(self):
        # Check that an interrupted context block restores the initial state.
        class LocalTestException(Exception):
            pass

        future = Future(cell_datetime_objects=False)
        try:
            with future.context(cell_datetime_objects=True):
                raise LocalTestException()
        except LocalTestException:
            pass
        self.assertEqual(future.cell_datetime_objects, False)
示例#12
0
    def test_exception(self):
        # Check that an interrupted context block restores the initial state.
        class LocalTestException(Exception):
            pass

        # Catch the deprecation when explicitly setting `cell_datetime_objects`
        # as the test is still useful even though the Future property is
        # deprecated.
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            future = Future(cell_datetime_objects=False)
            try:
                with future.context(cell_datetime_objects=True):
                    raise LocalTestException()
            except LocalTestException:
                pass
            self.assertEqual(future.cell_datetime_objects, False)
示例#13
0
    def test_exception(self):
        # Check that an interrupted context block restores the initial state.
        class LocalTestException(Exception):
            pass

        # Catch the deprecation when explicitly setting `cell_datetime_objects`
        # as the test is still useful even though the Future property is
        # deprecated.
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            future = Future(cell_datetime_objects=False)
            try:
                with future.context(cell_datetime_objects=True):
                    raise LocalTestException()
            except LocalTestException:
                pass
            self.assertEqual(future.cell_datetime_objects, False)
示例#14
0
 def test_netcdf_promote(self):
     future = Future()
     exp_emsg = "'Future' property 'netcdf_promote' is deprecated"
     with self.assertWarnsRegexp(exp_emsg):
         future.netcdf_promote = True
示例#15
0
 def test_invalid_netcdf_promote(self):
     future = Future()
     exp_emsg = "'Future' property 'netcdf_promote' has been deprecated"
     with self.assertRaisesRegexp(AttributeError, exp_emsg):
         future.netcdf_promote = False
示例#16
0
 def test_invalid_attribute(self):
     future = Future()
     with self.assertRaises(AttributeError):
         future.numberwang = 7
示例#17
0
 def test_valid_clip_latitudes(self):
     future = Future()
     new_value = not future.clip_latitudes
     future.clip_latitudes = new_value
     self.assertEqual(future.clip_latitudes, new_value)
示例#18
0
 def test_valid_strict_grib_load(self):
     future = Future()
     new_value = not future.strict_grib_load
     future.strict_grib_load = new_value
     self.assertEqual(future.strict_grib_load, new_value)
示例#19
0
 def test_valid_cell_datetime_objects(self):
     future = Future()
     new_value = not future.cell_datetime_objects
     future.cell_datetime_objects = new_value
     self.assertEqual(future.cell_datetime_objects, new_value)
示例#20
0
 def test_valid_netcdf_no_unlimited(self):
     future = Future()
     new_value = not future.netcdf_no_unlimited
     future.netcdf_no_unlimited = new_value
     self.assertEqual(future.netcdf_no_unlimited, new_value)
示例#21
0
 def test_netcdf_no_unlimited(self):
     future = Future()
     exp_emsg = "'Future' property 'netcdf_no_unlimited' is deprecated"
     with self.assertWarnsRegexp(exp_emsg):
         future.netcdf_no_unlimited = True
示例#22
0
 def test_invalid_netcdf_no_unlimited(self):
     future = Future()
     exp_emsg = \
         "'Future' property 'netcdf_no_unlimited' has been deprecated"
     with self.assertRaisesRegexp(AttributeError, exp_emsg):
         future.netcdf_no_unlimited = False
示例#23
0
 def test_invalid_netcdf_no_unlimited(self):
     future = Future()
     exp_emsg = \
         "'Future' property 'netcdf_no_unlimited' has been deprecated"
     with self.assertRaisesRegexp(AttributeError, exp_emsg):
         future.netcdf_no_unlimited = False
示例#24
0
 def test_invalid_attribute(self):
     future = Future()
     with self.assertRaises(AttributeError):
         future.numberwang = 7
示例#25
0
 def test_netcdf_no_unlimited(self):
     future = Future()
     exp_emsg = "'Future' property 'netcdf_no_unlimited' is deprecated"
     with self.assertWarnsRegexp(exp_emsg):
         future.netcdf_no_unlimited = True