예제 #1
0
def test_contains():
    now = datetime.now()

    tp1 = TimePeriod(now - timedelta(hours=1), now + timedelta(hours=1))
    tp2 = TimePeriod(now, now + timedelta(hours=1))
    assert tp1.contains(tp2)
    assert not tp2.contains(tp1)

    # if datetime is contained in period
    assert now in tp1
    assert now in tp2

    # __contains__  operator overloading
    assert tp2 in tp1
    assert tp1 not in tp2

    with pytest.raises(ValueError):
        assert 0 in tp1
def test_contains():
    now = datetime.now()

    tp1 = TimePeriod(now - timedelta(hours=1), now + timedelta(hours=1))
    tp2 = TimePeriod(now, now + timedelta(hours=1))
    assert tp1.contains(tp2)
    assert not tp2.contains(tp1)

    # if datetime is contained in period
    assert now in tp1
    assert now in tp2

    # __contains__  operator overloading
    assert tp2 in tp1
    assert tp1 not in tp2

    with pytest.raises(TypeError):
        assert 0 in tp1
예제 #3
0
 def test_contains(self):
     now = datetime.now()
     tp1 = TimePeriod(now - timedelta(hours=1), now + timedelta(hours=1))
     tp2 = TimePeriod(now, now + timedelta(hours=1))
     assert tp1.contains(tp2)
     assert not tp2.contains(tp1)