Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)