def test_prime(): assert ntheory.prime(1) == 2 assert ntheory.prime(27) == 103 with pytest.raises(ValueError): ntheory.prime(0) with pytest.raises(ValueError): ntheory.prime(-1)
def test_prime(self): self.assertEqual(prime(1), 2) self.assertEqual(prime(27), 103) self.assertRaises(ValueError, prime, 0) self.assertRaises(ValueError, prime, -1)
def _gen_primes(self): primecnt = 2 + int(1.5 * self._difficulty) prime_ind = [1] + random.sample(range(2, int(1.5 * primecnt)), primecnt - 1) primes = [ntheory.prime(i) for i in prime_ind] self._numgen = NumPrimeGenerator(primes)