Beispiel #1
0
def test_generate_range_on_edges():
    offset = to_offset("AS")
    start = datetime(2000, 1, 1)
    end = datetime(2100, 1, 1)

    res = generate_range(start, end, offset)
    exp = [datetime(y, 1, 1) for y in range(start.year, end.year + 1)]

    assert list(res) == exp
Beispiel #2
0
def test_generate_range(start, end):
    offset = to_offset("AS")
    start = start
    end = end

    res = generate_range(start, end, offset)
    exp = [datetime(y, 1, 1) for y in range(start.year, end.year + 2)]

    assert list(res) == exp
Beispiel #3
0
def test_month_start():
    offset = to_offset("MS")

    dt = datetime(2001, 2, 12)

    res = offset.rollback(dt)
    assert res.year == 2001
    assert res.month == 2
    assert res.day == 1

    res = offset.rollforward(dt)
    assert res.year == 2001
    assert res.month == 3
    assert res.day == 1
Beispiel #4
0
def test_invalid_offsets(offset_rule):
    with pytest.raises(ValueError):
        to_offset(offset_rule)