aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/tests/unit/framework/interfaces/base/_control.py')
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py20
1 files changed, 11 insertions, 9 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: