def test_unique(self): n = 100 core.clear_seed_rng() seeds1 = [core.get_random_seed() for _ in range(n)] self.assertEqual(len(set(seeds1)), n) seeds2 = [core.get_random_seed() for _ in range(n)] self.assertEqual(len(set(seeds2)), n) self.assertEqual(len(set(seeds2)) + len(set(seeds2)), 2 * n)
def test_unique(self): n = 100 core.clear_seed_rng() seeds1 = [core.get_random_seed() for _ in range(n)] assert len(set(seeds1)) == n seeds2 = [core.get_random_seed() for _ in range(n)] assert len(set(seeds2)) == n assert len(set(seeds2)) + len(set(seeds2)) == 2 * n
def test_unique_multiple_processes_no_init(self): n = 100 core.clear_seed_rng() # Would use with block here, but not supported in Py < 3.3. pool = multiprocessing.Pool(5) seeds = pool.map(get_seed, range(n)) self.assertEqual(len(set(seeds)), n) pool.terminate() pool.join()
def test_seed_generator_init(self): core.clear_seed_rng() seed = core.get_random_seed() self.assertGreater(seed, 0) self.assertIsNotNone(core.get_seed_rng())
def test_unique_multiple_processes_no_init(self): n = 100 core.clear_seed_rng() with multiprocessing.Pool(5) as pool: seeds = pool.map(get_seed, range(n)) assert len(set(seeds)) == n
def test_seed_generator_init(self): core.clear_seed_rng() seed = core.get_random_seed() assert seed > 0 assert core.get_seed_rng() is not None