diff -r c3a09c535001 Doc/library/unittest.rst --- a/Doc/library/unittest.rst Sat Feb 23 08:40:39 2013 +0200 +++ b/Doc/library/unittest.rst Sat Feb 23 19:54:02 2013 +0100 @@ -1510,6 +1510,10 @@ *start_dir* can be a dotted module name as well as a directory. + Paths are sorted before being imported to ensure execution order for a + given test suite is the same even if the underlying file system's ordering + is not dependent on file name like in ext3/4. + .. versionadded:: 3.2 diff -r c3a09c535001 Lib/unittest/loader.py --- a/Lib/unittest/loader.py Sat Feb 23 08:40:39 2013 +0200 +++ b/Lib/unittest/loader.py Sat Feb 23 19:54:02 2013 +0100 @@ -169,6 +169,9 @@ The pattern is deliberately not stored as a loader attribute so that packages can continue discovery themselves. top_level_dir is stored so load_tests does not need to pass this argument in to loader.discover(). + + Paths are sorted before being imported to ensure reproducible execution + order even on filesystems with non-alphabetical ordering like ext3/4. """ set_implicit_top = False if top_level_dir is None and self._top_level_dir is not None: @@ -245,7 +248,7 @@ def _find_tests(self, start_dir, pattern): """Used by discovery. Yields test suites it loads.""" - paths = os.listdir(start_dir) + paths = sorted(os.listdir(start_dir)) for path in paths: full_path = os.path.join(start_dir, path)