Exemplo n.º 1
0
def test_interval_invalid_issubset():
    class Impossible:
        def __init__(self):
            self.left = -1
            self.right = float("nan")

        def is_empty(self):
            return False

    interval = Interval(0, 1)
    other = Impossible()
    with pytest.raises(RuntimeError) as excinfo:
        interval.issubset(other)
    assert "XX" not in str(excinfo)
Exemplo n.º 2
0
def test_impossible_issubset():
    class Impossible:
        def __init__(self):
            self.left = -1
            self.right = float("nan")

        def is_empty(self):
            return False

    interval = Interval(0, 1)
    other = Impossible()
    with pytest.raises(RuntimeError) as exinfo:
        interval.issubset(other)
    msg = "issubset is only defined on Interval and IntervalUnion, but"
    assert str(exinfo.value).startswith(msg)
Exemplo n.º 3
0
def test_interval_issubset_interval_union():
    """
    * Neither of both is empty.
    * i2 is a subset of i1
    * i2 is an intervalUnion
    """
    i1 = Interval(6, 7)
    i2 = IntervalUnion([[2, 3], [5, 7]])
    assert i1.issubset(i2)
Exemplo n.º 4
0
def test_interval_union_issubset_not():
    iu = IntervalUnion([[0, 10], [20, 30], [40, 50]])
    interval = Interval(12, 14)
    assert not iu.issubset(interval)
    assert not interval.issubset(iu)