| Index: third_party/grpc/src/python/grpcio/tests/interop/_interop_test_case.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/memoized.py b/third_party/grpc/src/python/grpcio/tests/interop/_interop_test_case.py
|
| similarity index 56%
|
| copy from third_party/WebKit/Tools/Scripts/webkitpy/common/memoized.py
|
| copy to third_party/grpc/src/python/grpcio/tests/interop/_interop_test_case.py
|
| index 209abe4e7a2b33a683daaa738bf30433e5b1dcbd..ccea17a66da0a35f3a5cdfe09a6a942793bb5461 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/memoized.py
|
| +++ b/third_party/grpc/src/python/grpcio/tests/interop/_interop_test_case.py
|
| @@ -1,4 +1,5 @@
|
| -# Copyright (c) 2010 Google Inc. All rights reserved.
|
| +# Copyright 2015, Google Inc.
|
| +# All rights reserved.
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -26,31 +27,38 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -# Python does not (yet) seem to provide automatic memoization. So we've
|
| -# written a small decorator to do so.
|
| +"""Common code for unit tests of the interoperability test code."""
|
|
|
| -import functools
|
| +from tests.interop import methods
|
|
|
|
|
| -class memoized(object):
|
| +class InteropTestCase(object):
|
| + """Unit test methods.
|
|
|
| - def __init__(self, function):
|
| - self._function = function
|
| - self._results_cache = {}
|
| + This class must be mixed in with unittest.TestCase and a class that defines
|
| + setUp and tearDown methods that manage a stub attribute.
|
| + """
|
|
|
| - def __call__(self, *args):
|
| - try:
|
| - return self._results_cache[args]
|
| - except KeyError:
|
| - # If we didn't find the args in our cache, call and save the results.
|
| - result = self._function(*args)
|
| - self._results_cache[args] = result
|
| - return result
|
| - # FIXME: We may need to handle TypeError here in the case
|
| - # that "args" is not a valid dictionary key.
|
| + def testEmptyUnary(self):
|
| + methods.TestCase.EMPTY_UNARY.test_interoperability(self.stub, None)
|
|
|
| - # Use python "descriptor" protocol __get__ to appear
|
| - # invisible during property access.
|
| - def __get__(self, instance, owner):
|
| - # Return a function partial with obj already bound as self.
|
| - return functools.partial(self.__call__, instance)
|
| + def testLargeUnary(self):
|
| + methods.TestCase.LARGE_UNARY.test_interoperability(self.stub, None)
|
| +
|
| + def testServerStreaming(self):
|
| + methods.TestCase.SERVER_STREAMING.test_interoperability(self.stub, None)
|
| +
|
| + def testClientStreaming(self):
|
| + methods.TestCase.CLIENT_STREAMING.test_interoperability(self.stub, None)
|
| +
|
| + def testPingPong(self):
|
| + methods.TestCase.PING_PONG.test_interoperability(self.stub, None)
|
| +
|
| + def testCancelAfterBegin(self):
|
| + methods.TestCase.CANCEL_AFTER_BEGIN.test_interoperability(self.stub, None)
|
| +
|
| + def testCancelAfterFirstResponse(self):
|
| + methods.TestCase.CANCEL_AFTER_FIRST_RESPONSE.test_interoperability(self.stub, None)
|
| +
|
| + def testTimeoutOnSleepingServer(self):
|
| + methods.TestCase.TIMEOUT_ON_SLEEPING_SERVER.test_interoperability(self.stub, None)
|
|
|