def testSame(self): self.setup() orig = 1000 result = 7919 #start timing t1 = time() main.nthPrime(orig) t1 = time() - t1 #start timing t2 = time() ret = main.nthPrime(orig) t2 = time() - t2 self.assertEqual(ret, result) self.assertTrue(t2<(t1/2.0))
def testSame(self): self.setup() orig = 1000 result = 7919 #start timing t1 = time() main.nthPrime(orig) t1 = time() - t1 #start timing t2 = time() ret = main.nthPrime(orig) t2 = time() - t2 self.assertEqual(ret, result) self.assertTrue(t2 < (t1 / 2.0))
def testPast(self): self.setup() orig = 1001 result = 7919 #start timing t1 = time() main.nthPrime(orig) t1 = time() - t1 #start timing t2 = time() ret = main.nthPrime(orig-1) t2 = time() - t2 self.assertEqual(ret, result) print(t1) print t2 self.assertTrue(t2<(t1/2.0))
def testPast(self): self.setup() orig = 1001 result = 7919 #start timing t1_before = time() main.nthPrime(orig) t1_after = time() t1_duration = t1_after - t1_before #start timing t2_before = time() ret = main.nthPrime(orig - 1) t2_after = time() t2_duration = t2_after - t2_before self.assertEqual(ret, result) self.assertTrue(t2_duration < (t1_duration / 2.0))
def testPast(self): self.setup() orig = 1001 result = 7919 #start timing t1_before = time() main.nthPrime(orig) t1_after = time() t1_duration = t1_after - t1_before #start timing t2_before = time() ret = main.nthPrime(orig-1) t2_after = time() t2_duration = t2_after - t2_before self.assertEqual(ret, result) self.assertTrue(t2_duration<(t1_duration/2.0))
def testAllValid(self): self.setup() orig = 499 main.nthPrime(orig) self.assertEqual(main.nthPrime.primes, primes)
def testHundredth(self): self.setup() orig = 100 result = 541 self.assertEqual(main.nthPrime(orig), result)
def testFifth(self): orig = 5 result = 11 self.assertEqual(main.nthPrime(orig), result)
def testStored(self): self.setup() orig = 49 result = 50 main.nthPrime(orig) self.assertEqual(len(main.nthPrime.primes), result)
def testFirst(self): orig = 0 result = 1 self.assertEqual(main.nthPrime(orig), result)