[pycrypto] Issue with the new random.choice() unit test
Thorsten Behrens
sbehrens at gmx.li
Wed Jan 5 07:01:00 CST 2011
On 1/4/2011 6:24 PM, Lorenz Quack wrote:
> Well, this problem exist in all your random test although it is indeed
> unlikely that one will hit the others.
True. It also exists in all other random tests we have, in one form or
another.
> random tests. They all use random.randrange which in turn uses getrandbits.
> So if you want to go for *real* tests those functions should be the focus.
Aye. Real tests for those would be good, given the importance of
randomness in crypto.
I don't think I'm tackling that anytime soon, though.
> * You don't need to create the seq randomly or do you? wouldn't range(500) suffice?
It doesn't have to be random. I changed it to range(10000). Gets rid of
the too-too-likely collision, as well.
> * I find the way you fixed the shuffle function rather odd (good catch, though)
> my suggestion would be
> or even shorter
> for i in xrange(len(x)):
> x[i] = items.pop(self.randrange(len(items)))
That looks a lot more pythonic. Thanks, I've made that change. I'll hold
off on yet-another-pull-request though, poor Dwayne. :)
Do you have any ideas on the ailing AllOrNothing.py and random.sample on
Python 2.1? I haven't dug into those yet beyond
noting that they have issues, exposed by the new unit tests.
Yours
Thorsten
More information about the pycrypto
mailing list