Code0x58 closed pull request #2915: [WIP] Use six to make heronpy tests pass in 
python3
URL: https://github.com/apache/incubator-heron/pull/2915
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/heronpy/api/tests/python/serializer_unittest.py 
b/heronpy/api/tests/python/serializer_unittest.py
index 0f0c417719..65db24a3a9 100644
--- a/heronpy/api/tests/python/serializer_unittest.py
+++ b/heronpy/api/tests/python/serializer_unittest.py
@@ -23,6 +23,7 @@
 
 import unittest
 
+import six
 from heronpy.api.serializer import PythonSerializer
 
 prim_list = [1000, -234, 0.00023, "string",
@@ -39,6 +40,6 @@ def test_py_serializer(self):
     # Test with a list of primitive types
     for obj in prim_list:
       serialized = serializer.serialize(obj)
-      self.assertIsInstance(serialized, str)
+      self.assertIsInstance(serialized, six.binary_type)
       deserialized = serializer.deserialize(serialized)
       self.assertEqual(deserialized, obj)
diff --git a/heronpy/api/topology.py b/heronpy/api/topology.py
index 5af58734d8..485384d21b 100644
--- a/heronpy/api/topology.py
+++ b/heronpy/api/topology.py
@@ -26,10 +26,11 @@
 import uuid
 
 import heronpy.api.api_constants as api_constants
+import six
+from heronpy.api.component.component_spec import HeronComponentSpec
 from heronpy.api.serializer import default_serializer
 from heronpy.proto import topology_pb2
 
-from heronpy.api.component.component_spec import HeronComponentSpec
 
 class TopologyType(type):
   """Metaclass to define a Heron topology in Python"""
@@ -255,6 +256,7 @@ def _sanitize_config(custom_config):
 
     return sanitized
 
+@six.add_metaclass(TopologyType)
 class Topology(object):
   """Topology is an abstract class for defining a topology
 
@@ -285,7 +287,6 @@ class WordCount(Topology):
                                     inputs={word_spout: 
Grouping.fields('word')},
                                     config={"count_bolt.specific.config": 
"another value"})
   """
-  __metaclass__ = TopologyType
 
   # pylint: disable=no-member
   @classmethod
diff --git a/scripts/packages/heronpy/requirements.txt 
b/scripts/packages/heronpy/requirements.txt
index 40e388c222..6e235227fd 100644
--- a/scripts/packages/heronpy/requirements.txt
+++ b/scripts/packages/heronpy/requirements.txt
@@ -1 +1,2 @@
 protobuf==3.4.0
+six


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to