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

Side by Side Diff: tests/watchlists_unittest.py

Issue 132022: Fix watchlists for windows, for files with backslash (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | watchlists.py » ('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 watchlists.py.""" 6 """Unit tests for watchlists.py."""
7 7
8 import os
8 import unittest 9 import unittest
9 import super_mox 10 import super_mox
10 import watchlists 11 import watchlists
11 12
12 13
13 class WatchlistsTest(super_mox.SuperMoxTestBase): 14 class WatchlistsTest(super_mox.SuperMoxTestBase):
14 15
15 def setUp(self): 16 def setUp(self):
16 super_mox.SuperMoxTestBase.setUp(self) 17 super_mox.SuperMoxTestBase.setUp(self)
17 self.mox.StubOutWithMock(watchlists.Watchlists, '_HasWatchlistsFile') 18 self.mox.StubOutWithMock(watchlists.Watchlists, '_HasWatchlistsFile')
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 'views': %s, 121 'views': %s,
121 }, 122 },
122 } """ % (watchers, watchers) 123 } """ % (watchers, watchers)
123 watchlists.Watchlists._HasWatchlistsFile().AndReturn(True) 124 watchlists.Watchlists._HasWatchlistsFile().AndReturn(True)
124 watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents) 125 watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents)
125 self.mox.ReplayAll() 126 self.mox.ReplayAll()
126 127
127 wl = watchlists.Watchlists('/a/path') 128 wl = watchlists.Watchlists('/a/path')
128 self.assertEqual(wl.GetWatchersForPaths(['file_views_mac']), watchers) 129 self.assertEqual(wl.GetWatchersForPaths(['file_views_mac']), watchers)
129 130
131 def testWinPathWatchers(self):
132 """Test watchers for a windows path (containing backward slashes)."""
133 watchers = ['abc@def.com', 'x1@xyz.org']
134 contents = \
135 """{
136 'WATCHLIST_DEFINITIONS': {
137 'browser': {
138 'filepath': 'chrome/browser/.*',
139 },
140 },
141 'WATCHLISTS': {
142 'browser': %s,
143 },
144 } """ % watchers
145 saved_sep = os.sep
146 os.sep = '\\' # to pose as win32
147 watchlists.Watchlists._HasWatchlistsFile().AndReturn(True)
148 watchlists.Watchlists._ContentsOfWatchlistsFile().AndReturn(contents)
149 self.mox.ReplayAll()
150
151 wl = watchlists.Watchlists(r'a\path')
152 returned_watchers = wl.GetWatchersForPaths(
153 [r'chrome\browser\renderer_host\render_widget_host.h'])
154 os.sep = saved_sep # revert back os.sep before asserts
155 self.assertEqual(returned_watchers, watchers)
156
130 157
131 if __name__ == '__main__': 158 if __name__ == '__main__':
132 unittest.main() 159 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | watchlists.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698