def test_retry_signals_prefer_supplied_run_count_to_context():
    with prefect.context(task_run_count=5):
        with pytest.raises(PrefectStateSignal) as exc:
            raise RETRY(run_count=6)
    assert exc.value.state.run_count == 6
def test_retry_signals_take_run_count_from_context():
    with prefect.context(task_run_count=5):
        with pytest.raises(PrefectStateSignal) as exc:
            raise RETRY()
    assert exc.value.state.run_count == 5
def test_retry_signals_can_set_retry_time():
    date = pendulum.datetime(2019, 1, 1)
    with pytest.raises(PrefectStateSignal) as exc:
        raise RETRY(start_time=date)
    assert exc.value.state.start_time == date
def test_retry_signals_accept_run_count():
    with pytest.raises(PrefectStateSignal) as exc:
        raise RETRY(run_count=5)
    assert exc.value.state.run_count == 5
def test_retry_signals_carry_default_retry_time_on_state():
    with pytest.raises(Exception) as exc:
        raise RETRY()
    assert exc.value.state.start_time is not None
    now = pendulum.now("utc")
    assert now - exc.value.state.start_time < datetime.timedelta(seconds=0.1)