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

Subscribers

People subscribed via source and target branches

to all changes: