[Tutor] unittest with random population data
Steven D'Aprano
steve at pearwood.info
Sun May 31 01:41:35 CEST 2015
On Sat, May 30, 2015 at 12:16:01PM +0100, Sydney Shall wrote:
> I have written a unittest class which works OK.
> But the problem I have is that because I use the random module to
> populate my initial arrays, my data is not strictly predictable even
> though I am using seed(0).
Please show us how you populate your arrays, because what you describe
sounds wrong. Seeding to the same value should give the same sequence of
values:
py> import random
py> random.seed(0)
py> a = [random.random() for i in range(10**6)]
py> random.seed(0)
py> b = [random.random() for i in range(10**6)]
py> a == b
True
--
Steve
More information about the Tutor
mailing list