def test_medium_list_generation(self): prime3.prime_gen(10000) primes_under_1k = 1229 last_three = [9949, 9967, 9973] self.assertEqual(len(prime3.prime_list), primes_under_1k) self.assertEqual(prime3.prime_list[-3:], last_three)
def setUp(self): prime3.prime_gen(10)
def setUp(self): prime3.prime_gen(600)
def test_normal_usage(self): prime3.prime_gen(541) self.assertEqual(prime3.get_ordinal(541), 100)
def test_prime(self): prime3.prime_gen(7) self.assertEqual(7, prime3.latest_prime())
def test_twin_prime(self): prime3.prime_gen(18) self.assertEqual(17, prime3.latest_prime())
def test_composite(self): prime3.prime_gen(10) self.assertEqual(7, prime3.latest_prime())
def test_float(self): prime3.prime_gen(14.7) true_list = [2, 3, 5, 7, 11, 13] self.assertEqual(prime3.prime_list, true_list)
def test_policy_2(self): prime3.index_policy = 2 prime3.prime_gen(10) self.assertEqual({2: 1, 3: 2, 5: 3, 7: 4}, prime3.ordinal_index)
def test_policy_2(self): prime3.index_policy = 2 prime3.prime_gen(10) self.assertEqual({2:1, 3:2, 5:3, 7:4}, prime3.ordinal_index)
def test_float(self): prime3.prime_gen(14.7) true_list = [2, 3, 5, 7, 11 ,13] self.assertEqual(prime3.prime_list, true_list)
def test_small_list_generation(self): prime3.prime_gen(10) true_list = [2, 3, 5, 7] self.assertEqual(true_list, prime3.prime_list)
def test_composite_request(self): prime3.prime_gen(10) with self.assertRaises(Exception): prime3.get_ordinal(8)
#!C:\Python33\python.exe import sys import prime3 import timeit i = 1000 stepsize = 1000000 while i < sys.maxsize: print('primes up to', i, 'in') comstring = 'primegen.primegen(' + str(i) +', ' + str(stepsize) +')' print(comstring) prime3.prime_gen(i) print(len(prime_list)) #timeit.timeit(comstring, setup='import primegen') #timeit.timeit('primegen.primegen(100,1000000)', setup='import primegen') i=i*10
#!C:\Python33\python.exe import sys import prime3 import timeit i = 1000 stepsize = 1000000 while i < sys.maxsize: print('primes up to', i, 'in') comstring = 'primegen.primegen(' + str(i) + ', ' + str(stepsize) + ')' print(comstring) prime3.prime_gen(i) print(len(prime3.prime_list)) #timeit.timeit(comstring, setup='import primegen') #timeit.timeit('primegen.primegen(100,1000000)', setup='import primegen') i = i * 10