Repository: beam Updated Branches: refs/heads/release-2.0.0 f7e85e230 -> 3c6316abf
[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/40699172 Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/40699172 Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/40699172 Branch: refs/heads/release-2.0.0 Commit: 406991728c652b39c1f2bd031e5fef76fe6a4631 Parents: f7e85e2 Author: Robert Bradshaw <[email protected]> Authored: Mon May 8 14:54:17 2017 -0700 Committer: Robert Bradshaw <[email protected]> Committed: Tue May 9 09:37:07 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/40699172/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:
