コード例 #1
0
ファイル: datetime.py プロジェクト: joydu902/UofT-Coursework
def tz_args_strat(allow_naive, tz_list, name):
    if tz_list is None:
        tz_strat = timezones_strategy()
    else:
        tz_strat = st.sampled_from([
            tz if isinstance(tz, dt.tzinfo) else pytz.timezone(tz)
            for tz in tz_list
        ])
    if allow_naive or (allow_naive is None and tz_strat.is_empty):
        tz_strat = st.none() | tz_strat
    if tz_strat.is_empty:
        raise InvalidArgument(
            'Cannot create non-naive %s with no timezones allowed.' % name)
    return tz_strat
コード例 #2
0
ファイル: datetime.py プロジェクト: Wilfred/hypothesis-python
def tz_args_strat(allow_naive, tz_list, name):
    if tz_list is None:
        tz_strat = timezones_strategy()
    else:
        tz_strat = st.sampled_from([
            tz if isinstance(tz, dt.tzinfo) else pytz.timezone(tz)
            for tz in tz_list
        ])
    if allow_naive or (allow_naive is None and tz_strat.is_empty):
        tz_strat = st.none() | tz_strat
    if tz_strat.is_empty:
        raise InvalidArgument(
            'Cannot create non-naive %s with no timezones allowed.' % name)
    return tz_strat