summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/loader.py
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2013-03-19 00:50:12 (GMT)
committerMichael Foord <michael@voidspace.org.uk>2013-03-19 00:50:12 (GMT)
commit80cbc9e99835f3ae72c62999b4852beab76a9017 (patch)
tree476c4d24a6339cbba64f322f37ba58abc0208b0e /Lib/unittest/loader.py
parent7f6d79721d58962cb7914e8d8f4f5f717a8de8c0 (diff)
downloadcpython-80cbc9e99835f3ae72c62999b4852beab76a9017.zip
cpython-80cbc9e99835f3ae72c62999b4852beab76a9017.tar.gz
cpython-80cbc9e99835f3ae72c62999b4852beab76a9017.tar.bz2
Closes issue 16709. unittest test discovery sorts test files for consistent test ordering
Diffstat (limited to 'Lib/unittest/loader.py')
-rw-r--r--Lib/unittest/loader.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index 2077fa3..25a9122 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -177,6 +177,9 @@ class TestLoader(object):
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:
@@ -253,7 +256,7 @@ class TestLoader(object):
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)