aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/tests/unit/framework/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/tests/unit/framework/interfaces')
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py20
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py41
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py4
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py54
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_service.py38
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py5
11 files changed, 94 insertions, 96 deletions
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
index 38102b198a..0eb38abf22 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
@@ -29,6 +29,8 @@
"""Part of the tests of the base interface of RPC Framework."""
+from __future__ import division
+
import abc
import collections
import enum
@@ -36,6 +38,8 @@ import random # pylint: disable=unused-import
import threading
import time
+import six
+
from grpc.framework.interfaces.base import base
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.base import _sequence
@@ -45,8 +49,8 @@ from tests.unit.framework.interfaces.base import test_interfaces # pylint: disa
_GROUP = 'base test cases test group'
_METHOD = 'base test cases test method'
-_PAYLOAD_RANDOM_SECTION_MAXIMUM_SIZE = test_constants.PAYLOAD_SIZE / 20
-_MINIMUM_PAYLOAD_SIZE = test_constants.PAYLOAD_SIZE / 600
+_PAYLOAD_RANDOM_SECTION_MAXIMUM_SIZE = test_constants.PAYLOAD_SIZE // 20
+_MINIMUM_PAYLOAD_SIZE = test_constants.PAYLOAD_SIZE // 600
def _create_payload(randomness):
@@ -57,7 +61,7 @@ def _create_payload(randomness):
random_section = bytes(
bytearray(
randomness.getrandbits(8) for _ in range(random_section_length)))
- sevens_section = '\x07' * (length - random_section_length)
+ sevens_section = b'\x07' * (length - random_section_length)
return b''.join(randomness.sample((random_section, sevens_section), 2))
@@ -247,8 +251,7 @@ class Instruction(
CONCLUDE = 'CONCLUDE'
-class Controller(object):
- __metaclass__ = abc.ABCMeta
+class Controller(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def failed(self, message):
@@ -308,8 +311,7 @@ class Controller(object):
raise NotImplementedError()
-class ControllerCreator(object):
- __metaclass__ = abc.ABCMeta
+class ControllerCreator(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def name(self):
@@ -385,13 +387,13 @@ class _SequenceController(Controller):
return request + request
def deserialize_request(self, serialized_request):
- return serialized_request[:len(serialized_request) / 2]
+ return serialized_request[:len(serialized_request) // 2]
def serialize_response(self, response):
return response * 3
def deserialize_response(self, serialized_response):
- return serialized_response[2 * len(serialized_response) / 3:]
+ return serialized_response[2 * len(serialized_response) // 3:]
def invocation(self):
with self._condition:
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
index 84afd24d47..5eba475ba8 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
@@ -31,12 +31,13 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base # pylint: disable=unused-import
-class Serialization(object):
+class Serialization(six.with_metaclass(abc.ABCMeta)):
"""Specifies serialization and deserialization of test payloads."""
- __metaclass__ = abc.ABCMeta
def serialize_request(self, request):
"""Serializes a request value used in a test.
@@ -85,9 +86,8 @@ class Serialization(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Base layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(self, serializations, servicer):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index c8a3a1bc74..649892463a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_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,11 +29,15 @@
"""Test code for the Face layer of RPC Framework."""
+from __future__ import division
+
import abc
import itertools
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
@@ -46,14 +50,13 @@ from tests.unit.framework.interfaces.face import _stock_service
from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
-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 = 'BlockingInvocationInlineServiceTest'
@@ -81,7 +84,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()
@@ -92,7 +95,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()
@@ -104,7 +107,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()
@@ -115,7 +118,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()
@@ -127,7 +130,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()
@@ -145,7 +148,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(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 = []
@@ -167,7 +170,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 = {}
@@ -181,7 +184,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)
@@ -205,7 +208,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()
@@ -216,7 +219,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()
@@ -228,7 +231,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()
@@ -239,7 +242,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()
@@ -251,7 +254,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()
@@ -261,7 +264,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()
@@ -272,7 +275,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()
@@ -282,7 +285,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()
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
index 9304b6b1db..f0befb0b27 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
@@ -32,6 +32,8 @@
import collections
import threading
+import six
+
# test_control, _service, and test_interfaces are referenced from specification
# in this module.
from grpc.framework.common import cardinality
@@ -363,7 +365,7 @@ def _assemble(
events = {}
adaptations = {}
messages = {}
- for identifier, scenario in scenarios.iteritems():
+ for identifier, scenario in six.iteritems(scenarios):
if identifier in identifiers:
raise ValueError('Repeated identifier "(%s, %s)"!' % identifier)
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()
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
index 448e845a08..ac487bed4f 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.common import cardinality
_CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = {
@@ -62,9 +64,8 @@ _CARDINALITY_TO_MULTI_CALLABLE_ATTRIBUTE = {
}
-class Invoker(object):
+class Invoker(six.with_metaclass(abc.ABCMeta)):
"""A type used to invoke test RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking(self, group, name):
@@ -82,9 +83,8 @@ class Invoker(object):
raise NotImplementedError()
-class InvokerConstructor(object):
+class InvokerConstructor(six.with_metaclass(abc.ABCMeta)):
"""A type used to create Invokers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
index 42a7f4e3b8..48f31fc677 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.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
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
index 28941e2ad0..f13dff0558 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
@@ -31,16 +31,16 @@
import abc
+import six
+
# face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from tests.unit.framework.interfaces.face import test_interfaces
-class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(test_interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(test_interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(test_interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def unary_unary_scenarios(self):
"""Affords unary-request-unary-response test methods and their messages.
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
index 06b9d77e52..71de9d835e 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.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
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
index b2b5c10fa6..40f38e68ba 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
@@ -31,13 +31,14 @@
import abc
+import six
+
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""Specifies a method to be used in tests."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group(self):
@@ -126,9 +127,8 @@ class Method(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Face layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
index dace6c23f3..608e64119e 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.interfaces.links import links
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.links import test_utilities
@@ -58,13 +60,12 @@ _TRANSMISSION_GROUP = 'test.Group'
_TRANSMISSION_METHOD = 'TestMethod'
-class TransmissionTest(object):
+class TransmissionTest(six.with_metaclass(abc.ABCMeta)):
"""Tests ticket transmission between two connected links.
This class must be mixed into a unittest.TestCase that implements the abstract
methods it provides.
"""
- __metaclass__ = abc.ABCMeta
# This is a unittest.TestCase mix-in.
# pylint: disable=invalid-name