aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py')
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index 1d36a931e8..c3813d5f3a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2016, Google Inc.
+# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,8 @@
"""Test code for the Face layer of RPC Framework."""
+from __future__ import division
+
import abc
import contextlib
import itertools
@@ -36,6 +38,8 @@ import threading
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -67,6 +71,9 @@ class _PauseableIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._paused:
@@ -104,14 +111,13 @@ class _Callback(object):
self._condition.wait()
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'FutureInvocationAsynchronousEventServiceTest'
@@ -141,7 +147,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -156,7 +162,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -168,7 +174,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -188,7 +194,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@@ -204,7 +210,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSequentialInvocations(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -223,7 +229,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@@ -239,7 +245,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
test_messages.verify(second_request, second_response, self)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@@ -259,7 +265,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@@ -273,7 +279,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
some_completed_response_futures_iterator = itertools.islice(
futures.as_completed(response_futures_to_indices),
- test_constants.PARALLELISM / 2)
+ test_constants.PARALLELISM // 2)
for response_future in some_completed_response_futures_iterator:
index = response_futures_to_indices[response_future]
test_messages.verify(requests[index], response_future.result(), self)
@@ -281,7 +287,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -298,7 +304,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -312,7 +318,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -329,7 +335,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -343,7 +349,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -360,7 +366,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -372,7 +378,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -389,7 +395,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@@ -401,7 +407,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@@ -423,7 +429,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.unary_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@@ -438,7 +444,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_unary_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@@ -460,7 +466,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
- self._digest.stream_stream_messages_sequences.iteritems()):
+ six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()