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

Side by Side Diff: tests/watchlists_unittest.py

Issue 392006: Cleanup the unit tests by mocking more system functions. (Closed)
Patch Set: Created 11 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 | « tests/trychange_unittest.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 # 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 watchlists.py.""" 6 """Unit tests for watchlists.py."""
7 7
8 import os
9 import unittest
10 import super_mox 8 import super_mox
11 import watchlists 9 import watchlists
12 10
13 11
14 class WatchlistsTest(super_mox.SuperMoxTestBase): 12 class WatchlistsTest(super_mox.SuperMoxTestBase):
15 13
16 def setUp(self): 14 def setUp(self):
17 super_mox.SuperMoxTestBase.setUp(self) 15 super_mox.SuperMoxTestBase.setUp(self)
18 self.mox.StubOutWithMock(watchlists.Watchlists, '_HasWatchlistsFile') 16 self.mox.StubOutWithMock(watchlists.Watchlists, '_HasWatchlistsFile')
19 self.mox.StubOutWithMock(watchlists.Watchlists, '_ContentsOfWatchlistsFile') 17 self.mox.StubOutWithMock(watchlists.Watchlists, '_ContentsOfWatchlistsFile')
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 """{ 133 """{
136 'WATCHLIST_DEFINITIONS': { 134 'WATCHLIST_DEFINITIONS': {
137 'browser': { 135 'browser': {
138 'filepath': 'chrome/browser/.*', 136 'filepath': 'chrome/browser/.*',
139 }, 137 },
140 }, 138 },
141 'WATCHLISTS': { 139 'WATCHLISTS': {
142 'browser': %s, 140 'browser': %s,
143 }, 141 },
144 } """ % watchers 142 } """ % watchers
145 saved_sep = os.sep 143 saved_sep = watchlists.os.sep
146 os.sep = '\\' # to pose as win32 144 watchlists.os.sep = '\\' # to pose as win32
147 watchlists.Watchlists._HasWatchlistsFile().AndReturn(True) 145 watchlists.Watchlists._HasWatchlistsFile().AndReturn(True)
148 watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents) 146 watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents)
149 self.mox.ReplayAll() 147 self.mox.ReplayAll()
150 148
151 wl = watchlists.Watchlists(r'a\path') 149 wl = watchlists.Watchlists(r'a\path')
152 returned_watchers = wl.GetWatchersForPaths( 150 returned_watchers = wl.GetWatchersForPaths(
153 [r'chrome\browser\renderer_host\render_widget_host.h']) 151 [r'chrome\browser\renderer_host\render_widget_host.h'])
154 os.sep = saved_sep # revert back os.sep before asserts 152 watchlists.os.sep = saved_sep # revert back os.sep before asserts
155 self.assertEqual(returned_watchers, watchers) 153 self.assertEqual(returned_watchers, watchers)
156 154
157 155
158 if __name__ == '__main__': 156 if __name__ == '__main__':
157 import unittest
159 unittest.main() 158 unittest.main()
OLDNEW
« no previous file with comments | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698