def test_invalid_interval_additions(): i = Interval((0, False), (1, False)) vals = [Interval((-1, True), (0, False)), Interval((-1, False), (0, False)), Interval((1, False), (2, True)), Interval((1, False), (2, False)), Interval((3, True), (4, False)), Interval((3, False), (4, True)), Interval((3, False), (4, False)) ] for v in vals: yield raises(ValueError)(_add_intervals), i, v
def test_false_interval_intersections(): i = Interval((0, True), (1, True)) vals = [Interval((-1, True), (0, True)), Interval((-1, True), (0, False)), Interval((1, True), (2, True)), Interval((1, False), (2, True)), Interval((-2, True), (-1, True)), Interval((2, True), (3, True)) ] results = [True] * 5 + [False] intersect = lambda a, b, v: eq_(a & b, v, msg="{} & {} == {}".format(a, b, v)) for v, r in zip(vals, results): yield intersect, i, v, r
def test_sequential_interval_addition(self): i = Interval((2, True), (3, True)) result = Interval((0, False), (3, True)) eq_(self.i + i, result, msg="{}+{}={}".format(self.i, i, self.i + i))
def test_invalid_interval_creation(): Interval((1, True), (0, True))
def setUp(self): self.i = Interval((0, False), (2, False))
def test_nonsequential_interval_addition(self): i = Interval((-2, True), (0, True)) result = Interval((-2, True), (2, False)) eq_(i + self.i, result, msg="{}+{}={}".format(i, self.i, i + self.i))
def test_non_overlapping_interval(self): i = Interval((3, True), (4, True)) ok_(not self.i & i, msg="not {} & {}".format(self.i, i))
def test_overlapping_interval(self): i = Interval((2, True), (3, True)) ok_(self.i & i, msg="{} & {}".format(self.i, i))
def test_preceding_interval(self): i = Interval((2, True), (3, True)) ok_(self.i < i, msg="{} < {}".format(self.i, i))
def test_unequal_intervals(self): i = Interval((0, True), (1, True)) ok_(not self.i == i, msg="{} != {}".format(self.i, i))
def setUp(self): self.i = Interval((0, True), (2, True))