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

Side by Side Diff: tests/breakpad_unittest.py

Issue 9145001: Make sure that direct call to SendStack() doesn't send a stack trace for non googler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 11 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 | « breakpad.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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 breakpad.py.""" 6 """Unit tests for breakpad.py."""
7 7
8 import os 8 import os
9 import sys 9 import sys
10 10
11 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 11 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12 12
13 from testing_support.super_mox import SuperMoxTestBase 13 from testing_support.super_mox import SuperMoxTestBase
14 14
15 import breakpad 15 import breakpad
16 16
17 17
18 class Breakpad(SuperMoxTestBase): 18 class Breakpad(SuperMoxTestBase):
19 """Setups and tear downs the mocks but doesn't test anything as-is.""" 19 """Setups and tear downs the mocks but doesn't test anything as-is."""
20 def setUp(self): 20 def setUp(self):
21 super(Breakpad, self).setUp() 21 super(Breakpad, self).setUp()
22 self.mox.StubOutWithMock(breakpad.atexit, 'register') 22 self.mox.StubOutWithMock(breakpad.atexit, 'register')
23 self.mox.StubOutWithMock(breakpad.getpass, 'getuser') 23 self.mox.StubOutWithMock(breakpad.getpass, 'getuser')
24 self.mox.StubOutWithMock(breakpad.urllib2, 'urlopen') 24 self.mox.StubOutWithMock(breakpad.urllib2, 'urlopen')
25 breakpad._HOST_NAME = 'bozo' 25 breakpad._HOST_NAME = 'bozo'
26 self.assertEquals(False, breakpad.IS_ENABLED)
27 breakpad.IS_ENABLED = True
26 self._old_sys_argv = breakpad.sys.argv 28 self._old_sys_argv = breakpad.sys.argv
27 breakpad.sys.argv = ['my_test'] 29 breakpad.sys.argv = ['my_test']
28 self._old_sys_version = breakpad.sys.version 30 self._old_sys_version = breakpad.sys.version
29 breakpad.sys.version = 'random python' 31 breakpad.sys.version = 'random python'
30 32
31 def tearDown(self): 33 def tearDown(self):
34 breakpad.IS_ENABLED = False
32 breakpad.sys.version = self._old_sys_version 35 breakpad.sys.version = self._old_sys_version
33 breakpad.sys.argv = self._old_sys_argv 36 breakpad.sys.argv = self._old_sys_argv
34 super(Breakpad, self).tearDown() 37 super(Breakpad, self).tearDown()
35 38
36 def testMembersChanged(self): 39 def testMembersChanged(self):
37 members = [ 40 members = [
38 'CheckForException', 'DEFAULT_URL', 'FormatException', 'Register', 41 'CheckForException', 'DEFAULT_URL', 'FormatException', 'IS_ENABLED',
39 'SendProfiling', 'SendStack', 42 'Register', 'SendProfiling', 'SendStack',
40 'atexit', 'getpass', 'os', 'post', 'socket', 'sys', 'time', 'traceback', 43 'atexit', 'getpass', 'os', 'post', 'socket', 'sys', 'time', 'traceback',
41 'urllib', 'urllib2', 44 'urllib', 'urllib2',
42 ] 45 ]
43 # If this test fails, you should add the relevant test. 46 # If this test fails, you should add the relevant test.
44 self.compareMembers(breakpad, members) 47 self.compareMembers(breakpad, members)
45 48
46 def _part_1_setup_mocks(self, exception): 49 def _part_1_setup_mocks(self, exception):
47 breakpad.os.getcwd().AndReturn('/tmp/asdf') 50 breakpad.os.getcwd().AndReturn('/tmp/asdf')
48 breakpad.getpass.getuser().AndReturn('georges') 51 breakpad.getpass.getuser().AndReturn('georges')
49 obj = self.mox.CreateMockAnything() 52 obj = self.mox.CreateMockAnything()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 def testSendException(self): 114 def testSendException(self):
112 obj = Exception('foo') 115 obj = Exception('foo')
113 obj.msg = 'a message' 116 obj.msg = 'a message'
114 self._check(obj, 'foo\nMsg: a message') 117 self._check(obj, 'foo\nMsg: a message')
115 118
116 119
117 120
118 if __name__ == '__main__': 121 if __name__ == '__main__':
119 import unittest 122 import unittest
120 unittest.main() 123 unittest.main()
OLDNEW
« no previous file with comments | « breakpad.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698