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
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
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)
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)
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)
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)
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)
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)