From patchwork Wed Feb 2 17:40:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lo=C3=AFc_Minier?= X-Patchwork-Id: 64 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:39:38 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.5 with SMTP id b5cs22322yan; Wed, 2 Feb 2011 09:41:01 -0800 (PST) Received: by 10.227.143.194 with SMTP id w2mr9445473wbu.44.1296668460850; Wed, 02 Feb 2011 09:41:00 -0800 (PST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id c6si39473709wbi.96.2011.02.02.09.41.00; Wed, 02 Feb 2011 09:41:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1PkghO-0003FA-EG for ; Wed, 02 Feb 2011 17:40:58 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id D274D2E812A for ; Wed, 2 Feb 2011 17:40:53 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-maintainers/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 285 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 285: Factor the prefer_dir computation which had to be repeated in the previous Message-Id: <20110202174053.10088.40370.launchpad@loganberry.canonical.com> Date: Wed, 02 Feb 2011 17:40:53 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12274"; Instance="initZopeless config overlay" X-Launchpad-Hash: 9898b64ea3470d64fab3d1314ec8f310aa9d3165 ------------------------------------------------------------ revno: 285 committer: Loïc Minier branch nick: linaro-image-tools timestamp: Wed 2011-02-02 18:38:16 +0100 message: Factor the prefer_dir computation which had to be repeated in the previous merge. modified: linaro_media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_media_create/tests/test_media_create.py' --- linaro_media_create/tests/test_media_create.py 2011-02-02 17:32:10 +0000 +++ linaro_media_create/tests/test_media_create.py 2011-02-02 17:38:16 +0000 @@ -97,6 +97,14 @@ ) +def preferred_tools_dir(): + prefer_dir = None + # running from bzr checkout? + if not os.path.isabs(__file__): + prefer_dir = os.getcwd() + return prefer_dir + + class TestEnsureCommand(TestCaseWithFixtures): install_pkg_providing_called = False @@ -135,14 +143,14 @@ def test_existing_command(self): lmc = 'linaro-media-create' - # running from bzr checkout? - if os.path.isabs(__file__): + prefer_dir = preferred_tools_dir() + if prefer_dir is None: expected, _ = cmd_runner.run( ['which', lmc, ], stdout=subprocess.PIPE).communicate() expected = expected.strip() else: - expected = os.path.join(os.getcwd(), lmc) + expected = os.path.join(prefer_dir, lmc) self.assertEquals(expected, find_command(lmc)) def test_nonexisting_command(self): @@ -1112,10 +1120,7 @@ fixture = self.useFixture(MockCmdRunnerPopenFixture()) force_yes = True - prefer_dir = None - # running from bzr checkout? - if not os.path.isabs(__file__): - prefer_dir = os.getcwd() + prefer_dir = preferred_tools_dir() install_hwpacks( 'chroot', '/tmp/dir', prefer_dir, force_yes, 'hwpack1.tgz', @@ -1188,17 +1193,12 @@ linaro_media_create.hwpack, 'run_local_atexit_funcs', mock_run_local_atexit_functions)) - prefer_dir = None - # running from bzr checkout? - if not os.path.isabs(__file__): - prefer_dir = os.getcwd() - force_yes = True exception_caught = False try: install_hwpacks( - 'chroot', '/tmp/dir', prefer_dir, force_yes, 'hwp.tgz', - 'hwp2.tgz') + 'chroot', '/tmp/dir', preferred_tools_dir(), force_yes, + 'hwp.tgz', 'hwp2.tgz') except: exception_caught = True self.assertTrue(self.run_local_atexit_functions_called)