Beispiel #1
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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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)