コード例 #1
0
    def test_invalid_number(self):
        probabilities = {}
        probabilities['a'] = 1

        self.assertEqual(choose(probabilities, None), None)
        self.assertEqual(choose(probabilities, -1), None)
        self.assertEqual(choose(probabilities, 1), None)
コード例 #2
0
 def test_invalid_number(self):
     probabilities = {}
     probabilities['a'] = 1
     
     self.assertEqual(choose(probabilities, None), None)
     self.assertEqual(choose(probabilities, -1), None)
     self.assertEqual(choose(probabilities, 1), None)
コード例 #3
0
    def test_choose(self):
        probabilities = {}
        probabilities['a'] = 2
        probabilities['b'] = 1

        self.assertEqual(choose(probabilities, 0), 'a')
        self.assertEqual(choose(probabilities, 1), 'a')
        self.assertEqual(choose(probabilities, 2), 'b')
コード例 #4
0
 def test_choose(self):
     probabilities = {}
     probabilities['a'] = 2
     probabilities['b'] = 1
     
     self.assertEqual(choose(probabilities, 0), 'a')
     self.assertEqual(choose(probabilities, 1), 'a')
     self.assertEqual(choose(probabilities, 2), 'b')
コード例 #5
0
 def test_invalid_probabilities(self):
     self.assertEqual(choose(None, 0), None)
     self.assertEqual(choose({}, 0), None)
コード例 #6
0
 def test_invalid_probabilities(self):
     self.assertEqual(choose(None, 0), None)
     self.assertEqual(choose({}, 0), None)