Skip to content

Commit 96d9f5b

Browse files
committed
Avoid problem with temp file getting deleted
1 parent 2ca2f91 commit 96d9f5b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sdks/python/apache_beam/io/parquetio_test.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,16 @@ def test_write_batched_display_data(self):
337337
ARROW_MAJOR_VERSION >= 13,
338338
'pyarrow 13.x and above does not throw ArrowInvalid error')
339339
def test_sink_transform_int96(self):
340-
dst = tempfile.NamedTemporaryFile()
341-
path = dst.name
342-
# pylint: disable=c-extension-no-member
343340
with self.assertRaisesRegex(Exception, 'would lose data'):
344341
# Should throw an error "ArrowInvalid: Casting from timestamp[ns] to
345342
# timestamp[us] would lose data"
346-
with TestPipeline() as p:
347-
_ = p \
348-
| Create(self.RECORDS) \
349-
| WriteToParquet(
350-
path, self.SCHEMA96, num_shards=1, shard_name_template='')
343+
with tempfile.NamedTemporaryFile() as dst:
344+
path = dst.name
345+
with TestPipeline() as p:
346+
_ = p \
347+
| Create(self.RECORDS) \
348+
| WriteToParquet(
349+
path, self.SCHEMA96, num_shards=1, shard_name_template='')
351350

352351
def test_sink_transform(self):
353352
with TemporaryDirectory() as tmp_dirname:

0 commit comments

Comments
 (0)