From b0497e2a692f1f2fc30a5f2a2fc30d1b57ec275a Mon Sep 17 00:00:00 2001 From: manuzhang Date: Sat, 15 Sep 2018 09:00:25 +0800 Subject: [PATCH] Make all test inputs in bytes and decode --- .../options/pipeline_options_validator_test.py | 10 +++------- sdks/python/apache_beam/testing/test_pipeline.py | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sdks/python/apache_beam/options/pipeline_options_validator_test.py b/sdks/python/apache_beam/options/pipeline_options_validator_test.py index e1be6d69146c9..c28980c0ef827 100644 --- a/sdks/python/apache_beam/options/pipeline_options_validator_test.py +++ b/sdks/python/apache_beam/options/pipeline_options_validator_test.py @@ -311,7 +311,7 @@ def get_validator(matcher): '--staging_location=gs://foo/bar', '--temp_location=gs://foo/bar',] if matcher: - options.append('--on_success_matcher=' + matcher) + options.append('%s=%s' % ('--on_success_matcher=', matcher.decode())) pipeline_options = PipelineOptions(options) runner = MockRunners.TestDataflowRunner() @@ -322,18 +322,14 @@ def get_validator(matcher): 'errors': []}, {'on_success_matcher': pickler.dumps(AlwaysPassMatcher()), 'errors': []}, - {'on_success_matcher': 'abc', + {'on_success_matcher': b'abc', 'errors': ['on_success_matcher']}, {'on_success_matcher': pickler.dumps(object), 'errors': ['on_success_matcher']}, ] for case in test_case: - matcher = case['on_success_matcher'] - if matcher and type(matcher) is bytes: - errors = get_validator(matcher.decode('utf-8')).validate() - else: - errors = get_validator(matcher).validate() + errors = get_validator(case['on_success_matcher']).validate() self.assertEqual( self.check_errors_for_arguments(errors, case['errors']), []) diff --git a/sdks/python/apache_beam/testing/test_pipeline.py b/sdks/python/apache_beam/testing/test_pipeline.py index 4e4c92826860a..dc6044d9dc08c 100644 --- a/sdks/python/apache_beam/testing/test_pipeline.py +++ b/sdks/python/apache_beam/testing/test_pipeline.py @@ -152,7 +152,7 @@ def get_full_options_as_args(self, **extra_opts): elif isinstance(v, bool) and v: options.append('--%s' % k) elif 'matcher' in k: - options.append('--%s=%s' % (k, pickler.dumps(v))) + options.append('--%s=%s' % (k, pickler.dumps(v).decode())) else: options.append('--%s=%s' % (k, v)) return options