[ 
https://issues.apache.org/jira/browse/BEAM-5320?focusedWorklogId=167989&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-167989
 ]

ASF GitHub Bot logged work on BEAM-5320:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/18 21:44
            Start Date: 20/Nov/18 21:44
    Worklog Time Spent: 10m 
      Work Description: aaltay closed pull request #7029: [BEAM-5320] Finish 
Python 3 porting for testing module
URL: https://github.com/apache/beam/pull/7029
 
 
   

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/sdks/python/apache_beam/testing/synthetic_pipeline.py 
b/sdks/python/apache_beam/testing/synthetic_pipeline.py
index c76b9cd69049..e19ec25790ef 100644
--- a/sdks/python/apache_beam/testing/synthetic_pipeline.py
+++ b/sdks/python/apache_beam/testing/synthetic_pipeline.py
@@ -71,7 +71,7 @@ def div_round_up(a, b):
 def rotate_key(element):
   """Returns a new key-value pair of the same size but with a different key."""
   (key, value) = element
-  return key[-1] + key[:-1], value
+  return key[-1:] + key[:-1], value
 
 
 class SyntheticStep(beam.DoFn):
diff --git a/sdks/python/apache_beam/testing/synthetic_pipeline_test.py 
b/sdks/python/apache_beam/testing/synthetic_pipeline_test.py
index fe5e94a78cd5..e78655384120 100644
--- a/sdks/python/apache_beam/testing/synthetic_pipeline_test.py
+++ b/sdks/python/apache_beam/testing/synthetic_pipeline_test.py
@@ -125,7 +125,7 @@ def run_pipeline(self, barrier, writes_output=True):
     if writes_output:
       read_output = []
       for file_name in glob.glob(output_location + '*'):
-        with open(file_name, 'r') as f:
+        with open(file_name, 'rb') as f:
           read_output.extend(f.read().splitlines())
 
       self.assertEqual(10, len(read_output))
diff --git a/sdks/python/apache_beam/testing/test_utils.py 
b/sdks/python/apache_beam/testing/test_utils.py
index 1f0e99eec24a..f9aa128d0585 100644
--- a/sdks/python/apache_beam/testing/test_utils.py
+++ b/sdks/python/apache_beam/testing/test_utils.py
@@ -75,11 +75,14 @@ def create_temp_file(self, suffix='', lines=None):
 
 
 def compute_hash(content, hashing_alg=DEFAULT_HASHING_ALG):
-  """Compute a hash value from a list of string."""
+  """Compute a hash value of a list of objects by hashing their string
+  representations."""
+  content = [str(x).encode('utf-8') if not isinstance(x, bytes) else x
+             for x in content]
   content.sort()
   m = hashlib.new(hashing_alg)
   for elem in content:
-    m.update(str(elem).encode('utf-8'))
+    m.update(elem)
   return m.hexdigest()
 
 
diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini
index 09c794b16db8..cabff08cf1de 100644
--- a/sdks/python/tox.ini
+++ b/sdks/python/tox.ini
@@ -58,7 +58,7 @@ setenv =
   BEAM_EXPERIMENTAL_PY3=1
   RUN_SKIPPED_PY3_TESTS=0
 modules =
-  
apache_beam.typehints,apache_beam.coders,apache_beam.options,apache_beam.tools,apache_beam.utils,apache_beam.internal,apache_beam.metrics,apache_beam.portability,apache_beam.pipeline_test,apache_beam.pvalue_test,apache_beam.runners,apache_beam.io.hadoopfilesystem_test,apache_beam.io.hdfs_integration_test,apache_beam.io.gcp.tests.utils_test,apache_beam.io.gcp.big_query_query_to_table_it_test,apache_beam.io.gcp.bigquery_io_read_it_test,apache_beam.io.gcp.bigquery_test,apache_beam.io.gcp.gcsfilesystem_test,apache_beam.io.gcp.gcsio_test,apache_beam.io.gcp.pubsub_integration_test,apache_beam.io.hdfs_integration_test,apache_beam.io.gcp.internal,apache_beam.io.filesystem_test,apache_beam.io.filesystems,apache_beam.io.range_trackers_test,apache_beam.io.sources_test
+  
apache_beam.typehints,apache_beam.coders,apache_beam.options,apache_beam.tools,apache_beam.utils,apache_beam.internal,apache_beam.metrics,apache_beam.portability,apache_beam.pipeline_test,apache_beam.pvalue_test,apache_beam.runners,apache_beam.io.hadoopfilesystem_test,apache_beam.io.hdfs_integration_test,apache_beam.io.gcp.tests.utils_test,apache_beam.io.gcp.big_query_query_to_table_it_test,apache_beam.io.gcp.bigquery_io_read_it_test,apache_beam.io.gcp.bigquery_test,apache_beam.io.gcp.gcsfilesystem_test,apache_beam.io.gcp.gcsio_test,apache_beam.io.gcp.pubsub_integration_test,apache_beam.io.hdfs_integration_test,apache_beam.io.gcp.internal,apache_beam.io.filesystem_test,apache_beam.io.filesystems,apache_beam.io.range_trackers_test,apache_beam.io.sources_test,apache_beam.testing
 commands =
   python --version
   pip --version


 

----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 167989)
    Time Spent: 3h 20m  (was: 3h 10m)

> Finish Python 3 porting for testing module
> ------------------------------------------
>
>                 Key: BEAM-5320
>                 URL: https://issues.apache.org/jira/browse/BEAM-5320
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Robbe
>            Assignee: Robbe
>            Priority: Major
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to