[TIP] Randomizing test order with nose

Jesse Noller jnoller at gmail.com
Thu Apr 23 05:54:04 PDT 2009

On Wed, Apr 22, 2009 at 11:32 AM, Charles McCreary
<charles.mccreary at crmeng.com> wrote:
> About two years ago, Titus had a "random idea" in which he proposed a nose
> plugin that would randomize the test order. In one of the projects I'm
> involved in, that has turned out to be rather important. I can do this
> within the unittest framework with:
> class TestXMLHTTPResponder(unittest.
> TestCase):
> ... tests...
> if __name__ == "__main__":
>     import random
>     suite =
> unittest.TestLoader().loadTestsFromTestCase(TestXMLHTTPResponder)
>     random.shuffle(suite._tests)
>     unittest.TextTestRunner(verbosity=2).run(suite)
> But I use nose, so a plugin that would randomize the order would be helpful.
> Before I charge off and write one, has anyone already done it?
> Charles R. McCreary P.E.
> 13774 Hwy 322
> Kilgore, TX 75662
> Voice: 903.643.3490
> Fax: 866.804.1919


Yes, this would be nice as a nose plugin. For example, regrtest.py has
randomization for python-core tests which has exposed some nasty bugs
in the past, and I tend to need it for my nose-based deployments.

As others have said, being able to replay/seed so you can recreate the
exact execution time and time again would be a requirement for this.

Thank you, and let me know if you need a beta tester.


More information about the testing-in-python mailing list