Exemple #1
0
def test_relative_by_negative_two_with_default():
    assert relative_to([2, 4, 6, 9, 7], 9, offset=-2, default=16) == 4
Exemple #2
0
def test_relative_by_positive_two_with_default():
    assert relative_to([2, 4, 6, 9, 7], 4, offset=+2, default=12) == 9
Exemple #3
0
def test_relative_by_negative_one_with_default():
    assert relative_to([4, 6, 9], 6, offset=-1, default=14) == 4
Exemple #4
0
def test_relative_by_positive_one_with_default():
    assert relative_to([4, 6, 9], 6, offset=+1, default=5) == 9
Exemple #5
0
def test_relative_by_negative_one():
    assert relative_to([4, 6, 9], 6, offset=-1) == 4
Exemple #6
0
def test_relative_by_negative_zero_with_default():
    assert relative_to([4, 6, 9], 6, offset=0, default=9) == 6
Exemple #7
0
def test_relative_by_negative_three_to_oneth_occurrence():
    assert relative_to([2, 4, 5, 4, 6, 8, 10], 4, offset=-3, n=1) == 2
Exemple #8
0
def test_relative_by_positive_two_to_oneth_occurrence_with_default():
    assert relative_to([2, 4, 5, 4, 6, 8, 10], 4, offset=2, n=1,
                       default=12) == 8
Exemple #9
0
def test_relative_by_positive_two_out_of_range_raises_value_error():
    with raises(ValueError):
        relative_to([2, 4, 6, 9, 7], 9, offset=+2)
Exemple #10
0
def test_relative_by_positive_two_to_oneth_occurrence():
    assert relative_to([2, 4, 5, 4, 6, 8, 10], 4, offset=2, n=1) == 8
Exemple #11
0
def test_relative_by_positive_two():
    assert relative_to([2, 4, 6, 9, 7], 4, offset=+2) == 9
Exemple #12
0
def test_relative_by_negative_two():
    assert relative_to([2, 4, 6, 9, 7], 9, offset=-2) == 4
Exemple #13
0
def test_relative_by_positive_one():
    assert relative_to([4, 6, 9], 6, offset=+1) == 9
Exemple #14
0
def test_relative_by_negative_two_out_of_range_raises_value_error_with_default(
):
    assert relative_to([2, 4, 6, 9, 7], 4, offset=-2, default=97) == 97
Exemple #15
0
def test_relative_to_missing_item_return_default():
    assert relative_to([4, 6, 9], 12, offset=1, default=38) == 38
Exemple #16
0
def test_relative_by_positive_two_out_of_range_raises_value_error_with_default(
):
    assert relative_to([2, 4, 6, 9, 7], 9, offset=+2, default=67) == 67
Exemple #17
0
def test_relative_to_missing_item_raises_value_error():
    with raises(ValueError):
        relative_to([4, 6, 9], 12, offset=1)
Exemple #18
0
def test_relative_by_negative_three_to_oneth_occurrence_with_default():
    assert relative_to([2, 4, 5, 4, 6, 8, 10], 4, offset=-3, n=1,
                       default=37) == 2
Exemple #19
0
def test_relative_by_negative_zero():
    assert relative_to([4, 6, 9], 6, offset=0) == 6