Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: lib/naclports/tests/test_source_package.py

Issue 1422073003: Fix crash in source_package.py (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Native Client Authors. All rights reserved. 1 # Copyright 2014 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from mock import patch, Mock 5 from mock import patch, Mock
6 import mock 6 import mock
7 import tempfile 7 import tempfile
8 import textwrap 8 import textwrap
9 import shutil 9 import shutil
10 import os 10 import os
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 root = self.CreateTestPackage('foo') 90 root = self.CreateTestPackage('foo')
91 pkg = source_package.SourcePackage(root) 91 pkg = source_package.SourcePackage(root)
92 pkg.Build(True) 92 pkg.Build(True)
93 93
94 def testSourcePackageIterator(self): 94 def testSourcePackageIterator(self):
95 self.CreateTestPackage('foo') 95 self.CreateTestPackage('foo')
96 pkgs = [p for p in source_package.SourcePackageIterator()] 96 pkgs = [p for p in source_package.SourcePackageIterator()]
97 self.assertEqual(len(pkgs), 1) 97 self.assertEqual(len(pkgs), 1)
98 self.assertEqual(pkgs[0].NAME, 'foo') 98 self.assertEqual(pkgs[0].NAME, 'foo')
99 99
100 def testGetInstalledPackage(self):
101 root = self.CreateTestPackage('foo')
102 pkg = source_package.SourcePackage(root)
103 with self.assertRaisesRegexp(error.Error, 'package not installed: foo'):
104 pkg.GetInstalledPackage()
105
100 def testGetBuildLocation(self): 106 def testGetBuildLocation(self):
101 root = self.CreateTestPackage('foo') 107 root = self.CreateTestPackage('foo')
102 pkg = source_package.SourcePackage(root) 108 pkg = source_package.SourcePackage(root)
103 location = pkg.GetBuildLocation() 109 location = pkg.GetBuildLocation()
104 self.assertTrue(location.startswith(paths.BUILD_ROOT)) 110 self.assertTrue(location.startswith(paths.BUILD_ROOT))
105 self.assertEqual(os.path.basename(location), '%s-%s' % 111 self.assertEqual(os.path.basename(location), '%s-%s' %
106 (pkg.NAME, pkg.VERSION)) 112 (pkg.NAME, pkg.VERSION))
107 113
108 @patch('naclports.util.Log', Mock()) 114 @patch('naclports.util.Log', Mock())
109 def testExtract(self): 115 def testExtract(self):
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 expected_filename = os.path.join(paths.CACHE_ROOT, 'bar.tar.gz') 275 expected_filename = os.path.join(paths.CACHE_ROOT, 'bar.tar.gz')
270 mock_download.assert_called_once_with(expected_filename, mock.ANY) 276 mock_download.assert_called_once_with(expected_filename, mock.ANY)
271 mock_verify.assert_called_once_with(expected_filename, 'X123') 277 mock_verify.assert_called_once_with(expected_filename, 'X123')
272 278
273 @patch('naclports.util.DownloadFile') 279 @patch('naclports.util.DownloadFile')
274 def testDownloadMissingSHA1(self, mock_download): 280 def testDownloadMissingSHA1(self, mock_download):
275 self.CreateTestPackage('foo', 'URL=foo/bar') 281 self.CreateTestPackage('foo', 'URL=foo/bar')
276 pkg = source_package.CreatePackage('foo') 282 pkg = source_package.CreatePackage('foo')
277 with self.assertRaisesRegexp(error.Error, 'missing SHA1 attribute'): 283 with self.assertRaisesRegexp(error.Error, 'missing SHA1 attribute'):
278 pkg.Download() 284 pkg.Download()
OLDNEW
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698