aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/tests/unit/framework/face
diff options
context:
space:
mode:
authorGravatar Leifur Halldor Asgeirsson <lasgeirsson@zerofail.com>2016-03-04 12:46:55 -0500
committerGravatar Leifur Halldor Asgeirsson <lasgeirsson@zerofail.com>2016-03-18 15:58:19 -0400
commit1abda1f02ba2412ae845f1427370c52cef821756 (patch)
tree34eaf15b1fbda1ad4fe941f31ab0f967d4e223db /src/python/grpcio/tests/unit/framework/face
parent4302be789d89703d48f033c44720f828765f1467 (diff)
specify metaclasses in a py3-compatible way
Diffstat (limited to 'src/python/grpcio/tests/unit/framework/face')
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/base_util.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/control.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/coverage.py12
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/interfaces.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/service.py40
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/test_case.py7
9 files changed, 48 insertions, 58 deletions
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
index 1df1529b27..60ab5bc0fe 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import util as _base_util
from grpc.framework.base import implementations
@@ -43,7 +45,7 @@ _POOL_SIZE_LIMIT = 5
_MAXIMUM_TIMEOUT = 90
-class LinkedPair(object):
+class LinkedPair(six.with_metaclass(abc.ABCMeta)):
"""A Front and Back that are linked to one another.
Attributes:
@@ -51,8 +53,6 @@ class LinkedPair(object):
back: An interfaces.Back.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def shut_down(self):
"""Shuts down this object and releases its resources."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
index 0613516421..2fc67f6292 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.face import exceptions
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import control
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase(
- test_case.FaceTestCase, coverage.BlockingCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.BlockingCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/control.py b/src/python/grpcio/tests/unit/framework/face/testing/control.py
index 3960c4e649..0d40331e19 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/control.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,10 @@ import abc
import contextlib
import threading
+import six
-class Control(object):
+
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -43,8 +45,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
index f3aca113fe..9f5381069d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,15 +31,15 @@
import abc
+import six
+
# These classes are only valid when inherited by unittest.TestCases.
# pylint: disable=invalid-name
-class BlockingCoverage(object):
+class BlockingCoverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage for blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
raise NotImplementedError()
@@ -93,11 +93,9 @@ class BlockingCoverage(object):
raise NotImplementedError()
-class FullCoverage(BlockingCoverage):
+class FullCoverage(six.with_metaclass(abc.ABCMeta, BlockingCoverage)):
"""Specification of test coverage for non-blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testParallelInvocations(self):
raise NotImplementedError()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
index 179f3a2f67..b707dcdf6c 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import unittest
+import six
+
from grpc.framework.face import interfaces
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import callback as testing_callback
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
index 485524a356..4d27cbe186 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@ import contextlib
import threading
import unittest
+import six
+
from grpc.framework.face import exceptions
from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool
@@ -74,12 +76,12 @@ class _PauseableIterator(object):
class FutureInvocationAsynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
index 5932dabf1e..87be836e2d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
# cardinality is referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""An RPC method to be used in tests of RPC implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/service.py b/src/python/grpcio/tests/unit/framework/face/testing/service.py
index ac0b89b6ee..dc0f204c04 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/service.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,16 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces
-class UnaryUnaryTestMethodImplementation(interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-unary RPC 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(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(interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-stream RPC 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(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(interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-unary RPC 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(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(interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-stream RPC 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(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 RPC methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def name(self):
"""Identifies the RPC service name used during the test.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
index 23d4d919c2..5be9330a77 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,18 +31,19 @@
import abc
+import six
+
# face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
-class FaceTestCase(object):
+class FaceTestCase(six.with_metaclass(abc.ABCMeta)):
"""Describes a test of the Face Layer of RPC Framework.
Concrete subclasses must also inherit from unittest.TestCase and from at least
one class that defines test methods.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_up_implementation(