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

Side by Side Diff: appengine/monorail/framework/test/profiler_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Test for monorail.framework.profiler."""
7
8 import unittest
9
10 from framework import profiler
11
12
13 class ProfilerTest(unittest.TestCase):
14
15 def testTopLevelPhase(self):
16 prof = profiler.Profiler()
17 self.assertEquals(prof.current_phase.name, 'overall profile')
18 self.assertEquals(prof.current_phase.parent, None)
19 self.assertEquals(prof.current_phase, prof.top_phase)
20 self.assertEquals(prof.next_color, 0)
21
22 def testSinglePhase(self):
23 prof = profiler.Profiler()
24 self.assertEquals(prof.current_phase.name, 'overall profile')
25 with prof.Phase('test'):
26 self.assertEquals(prof.current_phase.name, 'test')
27 self.assertEquals(prof.current_phase.parent.name, 'overall profile')
28 self.assertEquals(prof.current_phase.name, 'overall profile')
29 self.assertEquals(prof.next_color, 1)
30
31 def testSubphaseExecption(self):
32 prof = profiler.Profiler()
33 try:
34 with prof.Phase('foo'):
35 with prof.Phase('bar'):
36 pass
37 with prof.Phase('baz'):
38 raise Exception('whoops')
39 except Exception as e:
40 self.assertEquals(e.message, 'whoops')
41 finally:
42 self.assertEquals(prof.current_phase.name, 'overall profile')
43 self.assertEquals(
44 prof.top_phase.subphases[0].subphases[1].name, 'baz')
45
46
47 if __name__ == '__main__':
48 unittest.main()
OLDNEW
« no previous file with comments | « appengine/monorail/framework/test/permissions_test.py ('k') | appengine/monorail/framework/test/ratelimiter_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698