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

Side by Side Diff: client/common_lib/test_unittest.py

Issue 6598041: Merge remote branch 'autotest-upstream/master' into merge-upstream (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 9 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 | « client/common_lib/test.py ('k') | client/tests/kvm/test_setup.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 2
3 """Unit Tests for autotest.client.common_lib.test""" 3 """Unit Tests for autotest.client.common_lib.test"""
4 4
5 __author__ = 'gps@google.com (Gregory P. Smith)' 5 __author__ = 'gps@google.com (Gregory P. Smith)'
6 6
7 import unittest 7 import unittest
8 from cStringIO import StringIO 8 from cStringIO import StringIO
9 import common 9 import common
10 from autotest_lib.client.common_lib import error, test 10 from autotest_lib.client.common_lib import error, test
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 self.god.stub_function(self.test, 'analyze_perf_constraints') 57 self.god.stub_function(self.test, 'analyze_perf_constraints')
58 before_hook = self.god.create_mock_function('before_hook') 58 before_hook = self.god.create_mock_function('before_hook')
59 after_hook = self.god.create_mock_function('after_hook') 59 after_hook = self.god.create_mock_function('after_hook')
60 self.test.register_before_iteration_hook(before_hook) 60 self.test.register_before_iteration_hook(before_hook)
61 self.test.register_after_iteration_hook(after_hook) 61 self.test.register_after_iteration_hook(after_hook)
62 62
63 # tests the test._call_run_once implementation 63 # tests the test._call_run_once implementation
64 self.test.drop_caches_between_iterations.expect_call() 64 self.test.drop_caches_between_iterations.expect_call()
65 before_hook.expect_call(self.test) 65 before_hook.expect_call(self.test)
66 self.test.run_once.expect_call(1, 2, arg='val') 66 self.test.run_once.expect_call(1, 2, arg='val')
67 after_hook.expect_call(self.test)
68 self.test.postprocess_iteration.expect_call() 67 self.test.postprocess_iteration.expect_call()
69 self.test.analyze_perf_constraints.expect_call([]) 68 self.test.analyze_perf_constraints.expect_call([])
69 after_hook.expect_call(self.test)
70 self.test._call_run_once([], False, None, (1, 2), {'arg': 'val'}) 70 self.test._call_run_once([], False, None, (1, 2), {'arg': 'val'})
71 self.god.check_playback() 71 self.god.check_playback()
72 72
73 73
74 def test_call_run_once_with_exception(self):
75 # setup
76 self.god.stub_function(self.test, 'drop_caches_between_iterations')
77 self.god.stub_function(self.test, 'run_once')
78 before_hook = self.god.create_mock_function('before_hook')
79 after_hook = self.god.create_mock_function('after_hook')
80 self.test.register_before_iteration_hook(before_hook)
81 self.test.register_after_iteration_hook(after_hook)
82 error = Exception('fail')
83
84 # tests the test._call_run_once implementation
85 self.test.drop_caches_between_iterations.expect_call()
86 before_hook.expect_call(self.test)
87 self.test.run_once.expect_call(1, 2, arg='val').and_raises(error)
88 after_hook.expect_call(self.test)
89 try:
90 self.test._call_run_once([], False, None, (1, 2), {'arg': 'val'})
91 except:
92 pass
93 self.god.check_playback()
94
95
74 def _expect_call_run_once(self): 96 def _expect_call_run_once(self):
75 self.test._call_run_once.expect_call((), False, None, (), {}) 97 self.test._call_run_once.expect_call((), False, None, (), {})
76 98
77 99
78 def test_execute_test_length(self): 100 def test_execute_test_length(self):
79 # test that test_length overrides iterations and works. 101 # test that test_length overrides iterations and works.
80 self.god.stub_function(self.test, '_call_run_once') 102 self.god.stub_function(self.test, '_call_run_once')
81 103
82 self._expect_call_run_once() 104 self._expect_call_run_once()
83 self._expect_call_run_once() 105 self._expect_call_run_once()
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 self.test.run_once_profiling.expect_call(True) 189 self.test.run_once_profiling.expect_call(True)
168 self.test.postprocess.expect_call() 190 self.test.postprocess.expect_call()
169 self.test.process_failed_constraints.expect_call() 191 self.test.process_failed_constraints.expect_call()
170 192
171 self.test.execute(postprocess_profiled_run=True, iterations=1) 193 self.test.execute(postprocess_profiled_run=True, iterations=1)
172 self.god.check_playback() 194 self.god.check_playback()
173 195
174 196
175 if __name__ == '__main__': 197 if __name__ == '__main__':
176 unittest.main() 198 unittest.main()
OLDNEW
« no previous file with comments | « client/common_lib/test.py ('k') | client/tests/kvm/test_setup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698