def testRoll200Times(self): roller = Dice() found1 = False found15 = False for _ in range(0, 200): value = roller.roll(2, 8, -1) self.assertTrue(value <= 15 and value >= 1) if value == 1: found1 = True if value == 15: found15 = True self.assertTrue(found1, 'Did not roll a 1') self.assertTrue(found15, 'Did not roll a 15')
def testRollByStringMod(self): roller = Dice() value = roller.rollString('2d8-1') self.assertTrue(value >= 1 and value <= 15)
def testRollByString(self): roller = Dice() value = roller.rollString('3d6') self.assertTrue(value >= 3 and value <= 18)
def testD20Disadvantage(self): roller = Dice() # rolling multiple times ensure we hit all lines in test for coverage for _ in range(1, 21): value = roller.d20Disadvantage() self.assertTrue(value >= 1 and value <= 20)
def testSimpleRoll(self): roller = Dice() value = roller.roll(1, 20, 0) self.assertTrue(value <= 20 and value >= 1, 'Value was {}'.format(value))
def testD20(self): roller = Dice() value = roller.d20() self.assertTrue(value >= 1 and value <= 20)
def testWithModifer(self): roller = Dice() value = roller.roll(1, 10, 5) self.assertTrue(value <= 15 and value >= 6)
def testMultipleDice(self): roller = Dice() value = roller.roll(3, 6, 0) self.assertTrue(value <= 18 and value >= 3)