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

Side by Side Diff: tests/revert_unittest.py

Issue 122040: Refactor the unit tests. (Closed)
Patch Set: even more cleanup Created 11 years, 6 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
« no previous file with comments | « tests/presubmit_unittest.py ('k') | tests/test-lib.sh » ('j') | 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 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for revert.py.""" 6 """Unit tests for revert.py."""
7 7
8 import os 8 import os
9 import unittest 9 import unittest
10 10
11 # Local imports 11 # Local imports
12 import revert 12 import revert
13 import super_mox
14 from super_mox import mox
13 15
14 16
15 class RevertTestsBase(unittest.TestCase): 17 class RevertTestsBase(super_mox.SuperMoxTestBase):
16 """Setups and tear downs the mocks but doesn't test anything as-is.""" 18 """Setups and tear downs the mocks but doesn't test anything as-is."""
17 def setUp(self): 19 pass
18 pass
19
20 def tearDown(self):
21 pass
22
23 def compareMembers(self, object, members):
24 """If you add a member, be sure to add the relevant test!"""
25 # Skip over members starting with '_' since they are usually not meant to
26 # be for public use.
27 actual_members = [x for x in sorted(dir(object))
28 if not x.startswith('_')]
29 expected_members = sorted(members)
30 if actual_members != expected_members:
31 diff = ([i for i in actual_members if i not in expected_members] +
32 [i for i in expected_members if i not in actual_members])
33 print diff
34 self.assertEqual(actual_members, expected_members)
35 20
36 21
37 class RevertUnittest(RevertTestsBase): 22 class RevertUnittest(RevertTestsBase):
38 """General revert.py tests.""" 23 """General revert.py tests."""
39 def testMembersChanged(self): 24 def testMembersChanged(self):
40 members = [ 25 members = [
41 'CaptureSVNLog', 'GetRepoBase', 'Main', 'ModifiedFile', 'NoBlameList', 26 'CaptureSVNLog', 'GetRepoBase', 'Main', 'ModifiedFile', 'NoBlameList',
42 'NoModifiedFile', 'OutsideOfCheckout', 'Revert', 'UniqueFast', 27 'NoModifiedFile', 'OutsideOfCheckout', 'Revert', 'UniqueFast',
43 'exceptions', 'gcl', 'gclient', 'optparse', 'os', 'sys', 'xml' 28 'exceptions', 'gcl', 'gclient', 'optparse', 'os', 'sys', 'xml'
44 ] 29 ]
45 # If this test fails, you should add the relevant test. 30 # If this test fails, you should add the relevant test.
46 self.compareMembers(revert, members) 31 self.compareMembers(revert, members)
47 32
48 33
49 if __name__ == '__main__': 34 if __name__ == '__main__':
50 unittest.main() 35 unittest.main()
OLDNEW
« no previous file with comments | « tests/presubmit_unittest.py ('k') | tests/test-lib.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698