Merge lp:~elopio/snapcraft/ubuntu-logger-bug into lp:~snappy-dev/snapcraft/core

Proposed by Leo Arias
Status: Merged
Approved by: Michael Terry
Approved revision: 124
Merged at revision: 125
Proposed branch: lp:~elopio/snapcraft/ubuntu-logger-bug
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 56 lines (+40/-1)
2 files modified
snapcraft/plugins/ubuntu.py (+1/-1)
snapcraft/tests/test_ubuntu_plugin.py (+39/-0)
To merge this branch: bzr merge lp:~elopio/snapcraft/ubuntu-logger-bug
Reviewer Review Type Date Requested Status
Michael Terry (community) Approve
Review via email: mp+267043@code.launchpad.net

Commit message

Fixed the call to the log from the ubuntu plugin, with a test.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/plugins/ubuntu.py'
2--- snapcraft/plugins/ubuntu.py 2015-07-23 14:23:29 +0000
3+++ snapcraft/plugins/ubuntu.py 2015-08-05 14:41:06 +0000
4@@ -89,7 +89,7 @@
5 for p in packages:
6 if p not in alldeps:
7 exit = True
8- logger.error('Package %s not recognized' % p, file=sys.stderr)
9+ logger.error("Package '{}' not recognized".format(p))
10 if exit:
11 sys.exit(1)
12
13
14=== added file 'snapcraft/tests/test_ubuntu_plugin.py'
15--- snapcraft/tests/test_ubuntu_plugin.py 1970-01-01 00:00:00 +0000
16+++ snapcraft/tests/test_ubuntu_plugin.py 2015-08-05 14:41:06 +0000
17@@ -0,0 +1,39 @@
18+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
19+#
20+# Copyright (C) 2015 Canonical Ltd
21+#
22+# This program is free software: you can redistribute it and/or modify
23+# it under the terms of the GNU General Public License version 3 as
24+# published by the Free Software Foundation.
25+#
26+# This program is distributed in the hope that it will be useful,
27+# but WITHOUT ANY WARRANTY; without even the implied warranty of
28+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+# GNU General Public License for more details.
30+#
31+# You should have received a copy of the GNU General Public License
32+# along with this program. If not, see <http://www.gnu.org/licenses/>.
33+
34+import logging
35+
36+import fixtures
37+
38+from snapcraft import tests
39+from snapcraft.plugins import ubuntu
40+
41+
42+class UbuntuPluginTestCase(tests.TestCase):
43+
44+ def test_get_all_dep_packages_with_unrecognized_package(self):
45+ fake_logger = fixtures.FakeLogger(level=logging.ERROR)
46+ self.useFixture(fake_logger)
47+
48+ test_options = type('obj', (object,), {'package': False})
49+ plugin = ubuntu.UbuntuPlugin('test_plugin', test_options)
50+
51+ with self.assertRaises(SystemExit) as raised:
52+ plugin.get_all_dep_packages(['test_package'])
53+
54+ self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.')
55+ self.assertEqual(
56+ "Package 'test_package' not recognized\n", fake_logger.output)

Subscribers

People subscribed via source and target branches

to all changes: