summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-09-28 11:16:28 +0000
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-11-03 17:12:04 +0000
commitaa2084e26003a18f068ae42dcdf94156c1401f09 (patch)
treeae143af93c2d68ff7c13efa83afd6129113a714c
parente47dcede79e5b7e5dccee485826e5dd97e53a5da (diff)
downloadmorph-aa2084e26003a18f068ae42dcdf94156c1401f09.tar.gz
Improve reliability of the staging area unit tests
Accordingly to [1], the listdir function (called by os.walk) returns a list of filepaths on an arbitrary order. Sort the list of file paths to produce always the same list. [1]: https://docs.python.org/2/library/os.html Change-Id: I4bb9842b1722f27a8becb9c50391cda089bb0a33
-rw-r--r--morphlib/stagingarea_tests.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py
index 2d7a7e33..12ea24b6 100644
--- a/morphlib/stagingarea_tests.py
+++ b/morphlib/stagingarea_tests.py
@@ -95,9 +95,9 @@ class StagingAreaTests(unittest.TestCase):
files = []
for dirname, subdirs, basenames in os.walk(root):
paths = [os.path.join(dirname, x) for x in basenames]
- for x in [dirname] + sorted(paths):
+ for x in [dirname] + paths:
files.append(x[len(root):] or '/')
- return files
+ return sorted(files)
def test_remembers_specified_directory(self):
self.assertEqual(self.sa.dirname, self.staging)
@@ -111,9 +111,9 @@ class StagingAreaTests(unittest.TestCase):
with open(chunk_tar, 'rb') as f:
self.sa.install_artifact(f)
self.assertEqual(self.list_tree(self.staging),
- ['/', '/file.txt',
- self.sa.relative_destdir(),
- self.sa.relative_builddir()])
+ sorted( ['/', '/file.txt',
+ self.sa.relative_destdir(),
+ self.sa.relative_builddir()]))
def test_removes_everything(self):
chunk_tar = self.create_chunk()