示例#1
0
def test_future_cancel():
    future = Future()
    assert future.cancel()
    assert future._state == futures.CANCELLED
    assert future.running is False
    assert future.cancelled
    assert future.done
示例#2
0
def test_future_cancel():
    future = Future()
    assert future.cancel()
    assert future._state == futures.CANCELLED
    assert future.running is False
    assert future.cancelled
    assert future.done
示例#3
0
    def test_json_dumps_futures(self):
        resolved = Future()
        resolved.set_finished("foo")
        self.assertEquals(json_dumps(resolved), '"foo"')

        pending = Future()
        with self.assertRaises(ExecutionBlocked):
            json_dumps(pending)
示例#4
0
    def test_json_dumps_futures(self):
        resolved = Future()
        resolved.set_finished("foo")
        self.assertEqual(json_dumps(resolved), '"foo"')

        pending = Future()
        with self.assertRaises(ExecutionBlocked):
            json_dumps(pending)
示例#5
0
def test_future_init_state():
    assert Future()._state == futures.PENDING
示例#6
0
def test_future_init_done():
    assert Future().done is False
示例#7
0
def test_future_init_running():
    assert Future().running is False
示例#8
0
def test_future_init_cancelled():
    assert Future().cancelled is False
示例#9
0
def test_future_init_repr():
    future = Future()
    assert repr(future) == '<Future at {} state=pending>'.format(
        hex(id(future)))
示例#10
0
def test_future_init_result():
    assert Future()._result is None