Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #16
0
 def test_invalid_attribute(self):
     future = Future()
     with self.assertRaises(AttributeError):
         future.numberwang = 7
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #24
0
 def test_invalid_attribute(self):
     future = Future()
     with self.assertRaises(AttributeError):
         future.numberwang = 7
Beispiel #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