Beispiel #1
0
def test_str_and_repr():
    linear_context = Context(100, False, 1)
    r = Region.create_from_ends(5,
                                10,
                                linear_context,
                                direction=Region.FORWARD)
    print(r)
    print(str(r))
Beispiel #2
0
def test_create_from_ends():
    linear_context = Context(100, False, 1)
    circular_context = Context(100, True, 1)

    # Test forward, linear
    r = Region.create_from_ends(5,
                                10,
                                linear_context,
                                direction=Region.FORWARD)
    assert r.left_end == 5 == r.start
    assert r.right_end == 10 == r.end

    r = Region.create_from_ends(5,
                                10,
                                linear_context,
                                direction=Region.REVERSE)
    assert r.left_end == 5 == r.end
    assert r.right_end == 10 == r.start

    # Test forward, linear with error
    with pytest.raises(RegionError):
        r = Region.create_from_ends(10,
                                    5,
                                    linear_context,
                                    direction=Region.FORWARD)
    with pytest.raises(RegionError):
        r = Region.create_from_ends(10,
                                    5,
                                    linear_context,
                                    direction=Region.REVERSE)

    # when left end > right end is ALWAYS means its circular
    r = Region.create_from_ends(10,
                                5,
                                circular_context,
                                direction=Region.FORWARD)
    assert r.left_end == 10
    assert r.right_end == 5
    assert r.start == 10
    assert r.end == 5

    r = Region.create_from_ends(10,
                                5,
                                circular_context,
                                direction=Region.REVERSE)
    assert r.left_end == 10
    assert r.right_end == 5
    assert r.start == 5
    assert r.end == 10