Ejemplo n.º 1
0
def test_dice_result_min_values():
    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([-1, 2, 10], d_type="d12")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result <= 0 not acceptable."

    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([0, 2, 19], d_type="d20")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result <= 0 not acceptable."
Ejemplo n.º 2
0
def test_dice_result_class():
    """
    result.d_type = d_type
    result.rolls = rolls
    result.mods = mods
    """
    test_result = dice.result([5, 2, 3])
    assert test_result.d_type == 'd6'
    assert type(test_result.mods) is list
    assert max(test_result.rolls) <= 6
Ejemplo n.º 3
0
def test_dice_result_max_values():

    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([5, 2, 3], d_type="d4")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result too high for this die type"

    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([5, 7, 3], d_type="d6")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result too high for this die type"

    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([5, 2, 9], d_type="d8")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result too high for this die type"

    with pytest.raises(ValueError) as excinfo:
        test_result = dice.result([5, 2, 19], d_type="d12")
    exception_msg = excinfo.value.args[0]
    assert exception_msg == "Die result too high for this die type"
Ejemplo n.º 4
0
def test_dice_result_successes_d12():
    test_result = dice.result([5, 2, 3], d_type="d12")
    assert test_result.successes == 0
    test_result = dice.result([5, 8, 2, 10, 3, 12], d_type="d12")
    assert test_result.successes == 1
Ejemplo n.º 5
0
def test_dice_result_successes_d10():
    test_result = dice.result([5, 2, 3], d_type="d10")
    assert test_result.successes == 0
    test_result = dice.result([10, 10, 10, 3], d_type="d10")
    assert test_result.successes == 3
Ejemplo n.º 6
0
def test_dice_result_successes_d8():
    test_result = dice.result([5, 2, 3], d_type="d8")
    assert test_result.successes == 0
    test_result = dice.result([8, 3, 2], d_type="d8")
    assert test_result.successes == 1
Ejemplo n.º 7
0
def test_dice_result_successes_d6():
    test_result = dice.result([5, 2, 3])  # default to d6
    assert test_result.successes == 0
    test_result = dice.result([5, 6, 2, 3, 6, 6])  # default to d6
    assert test_result.successes == 3
Ejemplo n.º 8
0
def test_dice_result_successes_d4():
    test_result = dice.result([1, 2, 3], d_type="d4")
    assert test_result.successes == 0
    test_result = dice.result([4, 2, 3, 1, 4], d_type="d4")
    assert test_result.successes == 2
Ejemplo n.º 9
0
def test_dice_result_sums_with_mods():
    test_result = dice.result([5, 2, 3], mods=[2])
    assert test_result.sums is 12

    test_result = dice.result([5, 2, 3], mods=[2, -4])
    assert test_result.sums is 8
Ejemplo n.º 10
0
def test_dice_result_sums():
    test_result = dice.result([5, 2, 3])
    assert test_result.sums is 10

    test_result = dice.result([1, 3])
    assert test_result.sums is 4
Ejemplo n.º 11
0
def test_dice_result_failures():
    test_result = dice.result([4, 2, 3], d_type="d4")
    assert test_result.failures == 0
    test_result = dice.result([4, 1, 2, 3, 3, 1], d_type="d4")
    assert test_result.failures == 2
Ejemplo n.º 12
0
def test_dice_result_successes_d20():
    test_result = dice.result([5, 2, 3], d_type="d20")
    assert test_result.successes == 0
    test_result = dice.result([5, 20, 2, 20, 19, 12], d_type="d20")
    assert test_result.successes == 2