예제 #1
0
 def includesProperNumberOfValues(self):
   values = range(10)
   for count in xrange(2, len(values)):
     self.assertEqual(
         len(handler._uniform_sample(values, count)), count,
         'Sampling %d values from 10 produced the wrong number of values' %
         count)
예제 #2
0
 def includesProperNumberOfValues(self):
     values = range(10)
     for count in xrange(2, len(values)):
         self.assertEqual(
             len(handler._uniform_sample(values, count)), count,
             'Sampling %d values from 10 produced the wrong number of values'
             % count)
예제 #3
0
 def testIncludesBeginningAndEnd(self):
     values = range(10)
     for count in xrange(2, len(values)):
         sampled = handler._uniform_sample(values, count)
         self.assertEqual(
             sampled[0], values[0],
             'Sampling %d values from 10 didn\'t start with the first value' %
             count)
         self.assertEqual(
             sampled[-1], values[-1],
             'Sampling %d values from 10 didn\'t end with the last value' % count)
예제 #4
0
 def testIncludesBeginningAndEnd(self):
   values = range(10)
   for count in xrange(2, len(values)):
     sampled = handler._uniform_sample(values, count)
     self.assertEqual(
         sampled[0], values[0],
         'Sampling %d values from 10 didn\'t start with the first value' %
         count)
     self.assertEqual(
         sampled[-1], values[-1],
         'Sampling %d values from 10 didn\'t end with the last value' % count)
예제 #5
0
    def testNonIntegerCountFails(self):
        with self.assertRaises(TypeError):
            handler._uniform_sample([1, 2, 3, 4], 3.14159)

        with self.assertRaises(TypeError):
            handler._uniform_sample([1, 2, 3, 4], 3.0)
예제 #6
0
 def testNotEnoughValues(self):
     self.assertEqual(handler._uniform_sample([1, 2, 3], 10), [1, 2, 3])
예제 #7
0
  def testNonIntegerCountFails(self):
    with self.assertRaises(TypeError):
      handler._uniform_sample([1, 2, 3, 4], 3.14159)

    with self.assertRaises(TypeError):
      handler._uniform_sample([1, 2, 3, 4], 3.0)
예제 #8
0
 def testNotEnoughValues(self):
   self.assertEqual(handler._uniform_sample([1, 2, 3], 10), [1, 2, 3])