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

Side by Side Diff: build/android/devil/utils/mock_calls.py

Issue 1390613002: Revert of [Android] Add a configurable environment for devil/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « build/android/devil/utils/lsusb.py ('k') | build/android/devil/utils/mock_calls_test.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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 A test facility to assert call sequences while mocking their behavior. 6 A test facility to assert call sequences while mocking their behavior.
7 """ 7 """
8 8
9 import os
9 import sys 10 import sys
10 import unittest 11 import unittest
11 12
12 from devil import devil_env 13 from pylib import constants
13 14
14 sys.path.append(devil_env.config.pymock_path) 15 sys.path.append(os.path.join(
16 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock'))
15 import mock # pylint: disable=F0401 17 import mock # pylint: disable=F0401
16 18
17 19
18 class TestCase(unittest.TestCase): 20 class TestCase(unittest.TestCase):
19 """Adds assertCalls to TestCase objects.""" 21 """Adds assertCalls to TestCase objects."""
20 class _AssertCalls(object): 22 class _AssertCalls(object):
21 def __init__(self, test_case, expected_calls, watched): 23 def __init__(self, test_case, expected_calls, watched):
22 def call_action(pair): 24 def call_action(pair):
23 if isinstance(pair, type(mock.call)): 25 if isinstance(pair, type(mock.call)):
24 return (pair, None) 26 return (pair, None)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 Raises: 173 Raises:
172 AssertionError if the watched targets do not receive the exact sequence 174 AssertionError if the watched targets do not receive the exact sequence
173 of calls specified. Missing calls, extra calls, and calls with 175 of calls specified. Missing calls, extra calls, and calls with
174 mismatching arguments, all cause the assertion to fail. 176 mismatching arguments, all cause the assertion to fail.
175 """ 177 """
176 return self._AssertCalls(self, calls, self._watched) 178 return self._AssertCalls(self, calls, self._watched)
177 179
178 def assertCall(self, call, action=None): 180 def assertCall(self, call, action=None):
179 return self.assertCalls((call, action)) 181 return self.assertCalls((call, action))
180 182
OLDNEW
« no previous file with comments | « build/android/devil/utils/lsusb.py ('k') | build/android/devil/utils/mock_calls_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698