Merge lp:~gz/workspace-runner/sorted_walk_results into lp:workspace-runner

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 26
Merged at revision: 26
Proposed branch: lp:~gz/workspace-runner/sorted_walk_results
Merge into: lp:workspace-runner
Diff against target: 17 lines (+6/-1)
1 file modified
workspace_runner/tests/__init__.py (+6/-1)
To merge this branch: bzr merge lp:~gz/workspace-runner/sorted_walk_results
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+299721@code.launchpad.net

Commit message

Fix test failures by applying stable ordering to os.walk results

Description of the change

Currently make test complains out of order walk results from the FakePrimitives test class.

<https://docs.python.org/2/library/os.html#os.walk>

Note os.walk does not promis ordering, but does let you manipulate dirnames in place with topdown=True to apply an order you desire. So, this branch just does that.

FAIL: test_s3_upload (workspace_runner.tests.__init__.TestRunFromConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "workspace_runner/tests/__init__.py", line 441, in test_s3_upload
    'upload.json', 'upload_artifacts.py'])
AssertionError: Lists differ: [('/tmp/tmp6gFog4', ['.wsr'], ... != [('/tmp/tmp6gFog4', ['.wsr'], ...

First differing element 1:
('/tmp/tmp6gFog4/.wsr', [], ['upload_artifacts.py', 'upload.json'])
('/tmp/tmp6gFog4/.wsr', [], ['upload.json', 'upload_artifacts.py'])

  [('/tmp/tmp6gFog4', ['.wsr'], []),
- ('/tmp/tmp6gFog4/.wsr', [], ['upload_artifacts.py', 'upload.json'])]
? ---------------

+ ('/tmp/tmp6gFog4/.wsr', [], ['upload.json', 'upload_artifacts.py'])]
? +++++++++++++++

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'workspace_runner/tests/__init__.py'
--- workspace_runner/tests/__init__.py 2015-10-09 18:32:02 +0000
+++ workspace_runner/tests/__init__.py 2016-07-11 18:11:39 +0000
@@ -72,7 +72,12 @@
72 return mkdtemp()72 return mkdtemp()
7373
74 def destroy(self):74 def destroy(self):
75 self.walk_results = list(os.walk(self.workspace))75 self.walk_results = []
76 for root, dirs, files in os.walk(self.workspace):
77 # Ensure walk happens in lexical order and results stored likewise.
78 dirs.sort()
79 files.sort()
80 self.walk_results.append((root, dirs, files))
76 rmtree(self.workspace)81 rmtree(self.workspace)
7782
78 def run(self, args, out_file):83 def run(self, args, out_file):

Subscribers

People subscribed via source and target branches