1 import unittest
2 import YootNori
3
4 class MockRandom:
5 def random(self):
6 return 0.5
7
8 YootNori.random.random = MockRandom().random
9
10 class TestYootNori(unittest.TestCase):
11 def testOneYoot(self):
12 theGame = YootNori.DoingYootNori(0.6)
13 self.assertEquals(1, theGame.throwOneYoot())
14 def testFourYoot(self):
15 theGame = YootNori.DoingYootNori(0.6)
16 self.assertEquals([1,1,1,1], theGame.throwFourYoot())
17 def testJudgeYoot(self):
18 theGame = YootNori.DoingYootNori(0.6)
19 self.assertEquals('MO', theGame.judgeYoot([1,1,1,1]))
20 def testThrow(self):
21 theGame = YootNori.DoingYootNori(0.6)
22 self.assertEquals('MO', theGame.throw())
23
24 class TestStatYootNori(unittest.TestCase):
25 def testTotalProbability(self):
26 theGame = YootNori.DoingYootNori(0.5)
27 totalProb = 0
28 for aYoot in YootNori.mapOfYootName.keys():
29 totalProb += theGame.getProbability(aYoot)
30
31 self.assertEquals(1, totalProb)
32
33 if __name__ == '__main__':
34 unittest.main(argv=('', '-v'))