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

Side by Side Diff: bin/loman_unittest.py

Issue 3385001: loman: don't report error when adding an exact duplicate. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Created 10 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « bin/loman.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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Unittests for loman.""" 7 """Unittests for loman."""
8 8
9 import os 9 import os
10 import StringIO 10 import StringIO
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 self.assertEqual( 45 self.assertEqual(
46 ptree.ToString(), 46 ptree.ToString(),
47 self.utf8 + '<manifest>\n' 47 self.utf8 + '<manifest>\n'
48 '<project name="foo" path="path/to/foo" workon="True" />\n' 48 '<project name="foo" path="path/to/foo" workon="True" />\n'
49 '</manifest>') 49 '</manifest>')
50 50
51 def testAddDup(self): 51 def testAddDup(self):
52 ptree = loman.LocalManifest('<manifest>\n</manifest>') 52 ptree = loman.LocalManifest('<manifest>\n</manifest>')
53 ptree.Parse() 53 ptree.Parse()
54 ptree.AddWorkonProject('foo', 'path/to/foo') 54 ptree.AddWorkonProject('foo', 'path/to/foo')
55 self.assertTrue(not ptree.AddWorkonProject('foo', 'path/to/foo')) 55 self.assertTrue(ptree.AddWorkonProject('foo', 'path/to/foo'))
56 self.assertTrue(not ptree.AddWorkonProject('foo', 'path/foo')) 56 self.assertTrue(not ptree.AddWorkonProject('foo', 'path/foo'))
57 self.assertTrue(not ptree.AddWorkonProject('foobar', 'path/to/foo')) 57 self.assertTrue(not ptree.AddWorkonProject('foobar', 'path/to/foo'))
58 58
59 class MainTest(unittest.TestCase): 59 class MainTest(unittest.TestCase):
60 60
61 def setUp(self): 61 def setUp(self):
62 self.utf8 = "<?xml version='1.0' encoding='UTF-8'?>\n" 62 self.utf8 = "<?xml version='1.0' encoding='UTF-8'?>\n"
63 self.tiny_manifest = '<manifest>\n</manifest>' 63 self.tiny_manifest = '<manifest>\n</manifest>'
64 self.stderr = sys.stderr 64 self.stderr = sys.stderr
65 sys.stderr = StringIO.StringIO() 65 sys.stderr = StringIO.StringIO()
(...skipping 29 matching lines...) Expand all
95 '<project name="foo" path="path/to/foo" workon="True" />\n' 95 '<project name="foo" path="path/to/foo" workon="True" />\n'
96 '</manifest>\n') 96 '</manifest>\n')
97 97
98 def testAddDup(self): 98 def testAddDup(self):
99 temp = tempfile.NamedTemporaryFile('w') 99 temp = tempfile.NamedTemporaryFile('w')
100 print >> temp, '<manifest>\n</manifest>' 100 print >> temp, '<manifest>\n</manifest>'
101 temp.flush() 101 temp.flush()
102 os.fsync(temp.fileno()) 102 os.fsync(temp.fileno())
103 loman.main(['loman', 'add', '--workon', '-f', 103 loman.main(['loman', 'add', '--workon', '-f',
104 temp.name, 'foo', 'path/to/foo']) 104 temp.name, 'foo', 'path/to/foo'])
105 loman.main(['loman', 'add', '--workon', '-f',
106 temp.name, 'foo', 'path/to/foo'])
105 self.assertRaises(SystemExit, loman.main, 107 self.assertRaises(SystemExit, loman.main,
106 ['loman', 'add', '--workon', '-f', 108 ['loman', 'add', '--workon', '-f',
107 temp.name, 'foo', 'path/to/foo']) 109 temp.name, 'foo', 'path/foo'])
108 110
109 111
110 if __name__ == '__main__': 112 if __name__ == '__main__':
111 unittest.main() 113 unittest.main()
OLDNEW
« no previous file with comments | « bin/loman.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698