Esempio n. 1
0
def test_relative_by_negative_two_with_default():
    assert relative_to([2, 4, 6, 9, 7], 9, offset=-2, default=16) == 4
Esempio n. 2
0
def test_relative_by_positive_two_with_default():
    assert relative_to([2, 4, 6, 9, 7], 4, offset=+2, default=12) == 9
Esempio n. 3
0
def test_relative_by_negative_one_with_default():
    assert relative_to([4, 6, 9], 6, offset=-1, default=14) == 4
Esempio n. 4
0
def test_relative_by_positive_one_with_default():
    assert relative_to([4, 6, 9], 6, offset=+1, default=5) == 9
Esempio n. 5
0
def test_relative_by_negative_one():
    assert relative_to([4, 6, 9], 6, offset=-1) == 4
Esempio n. 6
0
def test_relative_by_negative_zero_with_default():
    assert relative_to([4, 6, 9], 6, offset=0, default=9) == 6
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 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
Esempio n. 11
0
def test_relative_by_positive_two():
    assert relative_to([2, 4, 6, 9, 7], 4, offset=+2) == 9
Esempio n. 12
0
def test_relative_by_negative_two():
    assert relative_to([2, 4, 6, 9, 7], 9, offset=-2) == 4
Esempio n. 13
0
def test_relative_by_positive_one():
    assert relative_to([4, 6, 9], 6, offset=+1) == 9
Esempio n. 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
Esempio n. 15
0
def test_relative_to_missing_item_return_default():
    assert relative_to([4, 6, 9], 12, offset=1, default=38) == 38
Esempio n. 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
Esempio n. 17
0
def test_relative_to_missing_item_raises_value_error():
    with raises(ValueError):
        relative_to([4, 6, 9], 12, offset=1)
Esempio n. 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
Esempio n. 19
0
def test_relative_by_negative_zero():
    assert relative_to([4, 6, 9], 6, offset=0) == 6