Repository: beam Updated Branches: refs/heads/master 152c5bcc7 -> f315cc9ff
[BEAM-2224] Fix temp file management on Windows. Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/78c29238 Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/78c29238 Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/78c29238 Branch: refs/heads/master Commit: 78c29238aa471138fb55681d8700b095a3606e0d Parents: 152c5bc Author: Robert Bradshaw <rober...@gmail.com> Authored: Mon May 8 14:54:17 2017 -0700 Committer: Robert Bradshaw <rober...@gmail.com> Committed: Mon May 8 16:49:04 2017 -0700 ---------------------------------------------------------------------- .../runners/portability/maptask_executor_runner_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/78c29238/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py b/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py index b52c73c..aebd2e1 100644 --- a/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py +++ b/sdks/python/apache_beam/runners/portability/maptask_executor_runner_test.py @@ -16,6 +16,7 @@ # import logging +import os import tempfile import unittest @@ -181,12 +182,17 @@ class MapTaskExecutorRunnerTest(unittest.TestCase): assert_that(res, equal_to([('a', 1.5), ('b', 3.0)])) def test_read(self): - with tempfile.NamedTemporaryFile() as temp_file: + # Can't use NamedTemporaryFile as a context + # due to https://bugs.python.org/issue14243 + temp_file = tempfile.NamedTemporaryFile(delete=False) + try: temp_file.write('a\nb\nc') - temp_file.flush() + temp_file.close() with self.create_pipeline() as p: assert_that(p | beam.io.ReadFromText(temp_file.name), equal_to(['a', 'b', 'c'])) + finally: + os.unlink(temp_file.name) def test_windowing(self): with self.create_pipeline() as p: