Merge lp:~freyes/maas-deployer/fix-ls into lp:~maas-deployers/maas-deployer/next

Proposed by Felipe Reyes
Status: Merged
Merged at revision: 75
Proposed branch: lp:~freyes/maas-deployer/fix-ls
Merge into: lp:~maas-deployers/maas-deployer/next
Diff against target: 27 lines (+14/-3)
1 file modified
maas_deployer/tests/test_utils.py (+14/-3)
To merge this branch: bzr merge lp:~freyes/maas-deployer/fix-ls
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Review via email: mp+301709@code.launchpad.net

Description of the change

In Xenial the output of the path in ls for no such file or directory is
surrounded by single quotes, while in Trusty is not. This patch checks
for both possible outputs and if none is found, then the test is marked
as fail.

To post a comment you must log in.
Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'maas_deployer/tests/test_utils.py'
2--- maas_deployer/tests/test_utils.py 2015-09-14 09:24:08 +0000
3+++ maas_deployer/tests/test_utils.py 2016-08-01 19:45:22 +0000
4@@ -85,9 +85,20 @@
5 try:
6 util.execc(cmd1, pipedcmds=[cmd2])
7 except subprocess.CalledProcessError as exc:
8- self.assertEqual(exc.output,
9- "ls: cannot access %s: No such file or "
10- "directory\n" % (os.path.join(tmpdir, '1')))
11+ test_passed = False
12+ for msg in [("ls: cannot access %s: No such file or "
13+ "directory\n"),
14+ ("ls: cannot access '%s': No such file or "
15+ "directory\n")]:
16+ try:
17+ self.assertEqual(exc.output,
18+ msg % (os.path.join(tmpdir, '1')))
19+ test_passed = True
20+ break
21+ except AssertionError:
22+ pass
23+
24+ self.assertTrue(test_passed, exc.output)
25 self.assertEqual(exc.returncode, 2)
26 else:
27 raise UnitTestException("Exception not raised")

Subscribers

People subscribed via source and target branches