Re: Test-driven development of random algorithms

2006-11-13 Thread Ben Finney
Robert Kern <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: > > Does anyone have generic advice for the testing and development of > > this sort of function? > > "Design for Testability". In library code, never call the functions > in the random module. Always take as an argument a random.Ran

Re: Test-driven development of random algorithms

2006-11-13 Thread Robert Kern
Steven D'Aprano wrote: > I'm working on some functions that, essentially, return randomly generated > strings. Here's a basic example: > > def rstr(): > """Return a random string based on a pseudo > normally-distributed random number. > """ > x = 0.0 > for i in range(12): >

Test-driven development of random algorithms

2006-11-13 Thread Steven D'Aprano
I'm working on some functions that, essentially, return randomly generated strings. Here's a basic example: def rstr(): """Return a random string based on a pseudo normally-distributed random number. """ x = 0.0 for i in range(12): x += random.random() return str(i