def test_toomanydice(self): with raises(DiceFatalException): roll('%id6' % (MAX_ROLL_DICE + 1)) with raises(DiceFatalException): roll('7d6', max_dice=6) with raises(ValueError): Roll.roll(6, 1, 6, max_dice=4)
def test_toomanydice(self): with raises(DiceFatalException): roll("%id6" % (MAX_ROLL_DICE + 1)) with raises(DiceFatalException): roll("7d6", max_dice=6) with raises(ValueError): Roll.roll(6, 1, 6, max_dice=4)
def test_roll(self): amount, sides = 6, 6 assert len(Roll.roll(amount, 1, sides)) == amount rr = Roll.roll(amount, 1, sides) assert (1 * sides) <= sum(rr) <= (amount * sides) rr = roll('%id%i' % (amount, sides)) rmin, rmax = rr.random_element.min_value, rr.random_element.max_value assert rmin <= rr.do_roll_single() <= rmax
def test_roll_error(self): with raises(ValueError): Roll.roll(-1, 1, 6) with raises(ValueError): Roll.roll_single(4, 3) with raises(DiceFatalException): rolled = roll('6d6') rolled.do_roll_single(4, 3)
def test_roll(self): amount, sides = 6, 6 assert len(Roll.roll(amount, sides)) == amount assert (1 * sides) <= sum(Roll.roll(amount, sides)) <= (amount * sides)
def test_negative_amount_extreme(self): with raises(ValueError): Roll.roll(-1, 1, 6, force_extreme=DiceExtreme.EXTREME_MAX)