This is an automated email from the ASF dual-hosted git repository. altay pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 772fa67 [BEAM-5320] Finish Python 3 porting for testing module (#7029) 772fa67 is described below commit 772fa67d62703f9462f1ee97ae7a3b94e8655659 Author: Robbe Sneyders <robbe.sneyd...@gmail.com> AuthorDate: Tue Nov 20 22:44:47 2018 +0100 [BEAM-5320] Finish Python 3 porting for testing module (#7029) * Finish Python 3 porting for testing module * Convert objects to bytes before calculating hash --- sdks/python/apache_beam/testing/synthetic_pipeline.py | 2 +- sdks/python/apache_beam/testing/synthetic_pipeline_test.py | 2 +- sdks/python/apache_beam/testing/test_utils.py | 7 +++++-- sdks/python/tox.ini | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sdks/python/apache_beam/testing/synthetic_pipeline.py b/sdks/python/apache_beam/testing/synthetic_pipeline.py index c76b9cd..e19ec25 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 fe5e94a..e786553 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 @@ class SyntheticPipelineTest(unittest.TestCase): 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 1f0e99e..f9aa128 100644 --- a/sdks/python/apache_beam/testing/test_utils.py +++ b/sdks/python/apache_beam/testing/test_utils.py @@ -75,11 +75,14 @@ class TempDir(object): 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 09c794b..cabff08 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. [...] + 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. [...] commands = python --version pip --version