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."
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
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"
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
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
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
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
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
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
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
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
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