Re: doctest random output?

2019-04-17 Thread duncan smith
On 28/08/2017 20:17, Leam Hall wrote: > On 08/28/2017 11:40 AM, Dennis Lee Bieber wrote: > > ... a bunch of good stuff ... > > I'm (re-)learning python and just trying make sure my function works. > Not at the statistical or cryptographic level.   :) > > Thanks! > > Leam If it's supposed to

Re: doctest random output?

2017-08-29 Thread Chris Angelico
On Wed, Aug 30, 2017 at 1:39 AM, Stefan Ram wrote: > Dennis Lee Bieber writes: >>Testing randomness itself requires statistical tests... > > A perfectly random coin /can/ yield "heads" a thousand times > in sequence (which is very unlikely, but

Re: doctest random output?

2017-08-29 Thread Pavol Lisy
On 8/28/17, Leam Hall wrote: > On 08/28/2017 11:40 AM, Dennis Lee Bieber wrote: > > ... a bunch of good stuff ... > > I'm (re-)learning python and just trying make sure my function works. > Not at the statistical or cryptographic level. :) > > Thanks! > > Leam > -- >

To mock/patch or not to, was Re: doctest random output?

2017-08-29 Thread Peter Otten
Steven D'Aprano wrote: > Wait... are you saying that importing test_mymodule monkey-patches the > current library? And doesn't un-patch it afterwards? That's horrible. There's something in the library, unittest.mock that makes this relatively safe -- if not painless with

Re: doctest random output?

2017-08-29 Thread Chris Angelico
On Tue, Aug 29, 2017 at 5:39 PM, Steven D'Aprano wrote: > On Tue, 29 Aug 2017 12:25:45 +1000, Chris Angelico wrote: > >> For a lot of functions, this completely destroys the value of >> doctesting. > > > "The" value? Doc tests have two values: documentation

Re: doctest random output?

2017-08-29 Thread Steven D'Aprano
On Tue, 29 Aug 2017 12:25:45 +1000, Chris Angelico wrote: > On Tue, Aug 29, 2017 at 11:53 AM, Steve D'Aprano > wrote: >> (1) Disable doctesting for that example, and treat it as just >> documentation: >> >> def my_thing(): >> """blah blah blah >> >> >>>

Re: doctest random output?

2017-08-28 Thread Chris Angelico
On Tue, Aug 29, 2017 at 11:53 AM, Steve D'Aprano wrote: > (1) Disable doctesting for that example, and treat it as just documentation: > > def my_thing(): > """blah blah blah > > >>> my_thing() #doctest:+SKIP > 4 > > """ For a lot of functions, this

Re: doctest random output?

2017-08-28 Thread Steve D'Aprano
On Mon, 28 Aug 2017 07:41 pm, Leam Hall wrote: > Is this a good way to test if random numeric output? It seems to work > under Python 2.6 and 3.6 but that doesn't make it 'good'. That depends on what you are actually testing. If you are intending to test the statistical properties of random,

Re: doctest random output?

2017-08-28 Thread Leam Hall
On 08/28/2017 11:40 AM, Dennis Lee Bieber wrote: ... a bunch of good stuff ... I'm (re-)learning python and just trying make sure my function works. Not at the statistical or cryptographic level. :) Thanks! Leam -- https://mail.python.org/mailman/listinfo/python-list

Re: doctest random output?

2017-08-28 Thread Peter Otten
Leam Hall wrote: > Is this a good way to test if random numeric output? It seems to work > under Python 2.6 and 3.6 but that doesn't make it 'good'. > > ### Code > import random > > def my_thing(): >""" Return a random number from 1-6 >>>> 0 < my_thing() <=6 >True >>>> 6 <

doctest random output?

2017-08-28 Thread Leam Hall
Is this a good way to test if random numeric output? It seems to work under Python 2.6 and 3.6 but that doesn't make it 'good'. ### Code import random def my_thing(): """ Return a random number from 1-6 >>> 0 < my_thing() <=6 True >>> 6 < my_thing() False """ return