Thanks John and others, Replies much appreciated. I don't know how it could affect the results, but the function being tested is using redis. And I am running the test code under PyCharm, so perhaps using the module-level random number generator wasn't such a good idea. Live and learn.
In response to your question, John, all I know is that my own code doesn't use the random module outside of this code fragment. Ned, thanks for the tip about creating a new instance of Random(). The test failures are still happening when the stockbins are randomised (as in code below.) That is suggesting that my code is somehow at fault. Peter, I am using PyCharm as I said. But using a new Random() object to generate the sequence doesn't solve the problem apparently. The code now looks like this: rnd = random.Random() ... for qty in [4, 0]: rnd.seed(seed) for cart in range(test_size): for special in range(rnd.randrange(3)): s.addUpdate_special_to_cart(cart=cart, stockbin=rnd.randrange(test_size), special_id=rnd.randrange(test_size), special_qty=qty, products=[(rnd.choice(PRODUCTS), rnd.choice(range(10))) for r in range(rnd.randrange(7))]) Cheers, Nick -- https://mail.python.org/mailman/listinfo/python-list