Repository: incubator-beam Updated Branches: refs/heads/python-sdk 4a660c604 -> 43057960a
Fix template_runner_test on Windows Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/a565ca10 Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/a565ca10 Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/a565ca10 Branch: refs/heads/python-sdk Commit: a565ca1008309564dba41d551c68ea553cd83a7b Parents: 4a660c6 Author: Charles Chen <c...@google.com> Authored: Wed Dec 7 16:09:49 2016 -0800 Committer: Charles Chen <c...@google.com> Committed: Wed Dec 7 16:09:49 2016 -0800 ---------------------------------------------------------------------- .../apache_beam/runners/template_runner_test.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/a565ca10/sdks/python/apache_beam/runners/template_runner_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/template_runner_test.py b/sdks/python/apache_beam/runners/template_runner_test.py index a141521..cc3d7c2 100644 --- a/sdks/python/apache_beam/runners/template_runner_test.py +++ b/sdks/python/apache_beam/runners/template_runner_test.py @@ -33,24 +33,30 @@ from apache_beam.internal import apiclient class TemplatingDataflowPipelineRunnerTest(unittest.TestCase): """TemplatingDataflow tests.""" def test_full_completion(self): - dummy_file = tempfile.NamedTemporaryFile() + # Create dummy file and close it. Note that we need to do this because + # Windows does not allow NamedTemporaryFiles to be reopened elsewhere + # before the temporary file is closed. + dummy_file = tempfile.NamedTemporaryFile(delete=False) + dummy_file_name = dummy_file.name + dummy_file.close() + dummy_dir = tempfile.mkdtemp() remote_runner = DataflowPipelineRunner() pipeline = Pipeline(remote_runner, options=PipelineOptions([ '--dataflow_endpoint=ignored', - '--sdk_location=' + dummy_file.name, + '--sdk_location=' + dummy_file_name, '--job_name=test-job', '--project=test-project', '--staging_location=' + dummy_dir, '--temp_location=/dev/null', - '--template_location=' + dummy_file.name, + '--template_location=' + dummy_file_name, '--no_auth=True'])) pipeline | beam.Create([1, 2, 3]) | beam.Map(lambda x: x) # pylint: disable=expression-not-assigned pipeline.run() - with open(dummy_file.name) as template_file: + with open(dummy_file_name) as template_file: saved_job_dict = json.load(template_file) self.assertEqual( saved_job_dict['environment']['sdkPipelineOptions']