Skip to content

Commit 3292d1e

Browse files
committed
move addCleanup call to tempfile
1 parent 83afce1 commit 3292d1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/test/test_pickletools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ def check_output(self, data, expect, *flags):
553553
def test_invocation(self):
554554
# test various combinations of parameters
555555
output_file = tempfile.mktemp()
556+
self.addCleanup(os_helper.unlink, output_file)
556557
base_flags = [
557558
(f'-o={output_file}', f'--output={output_file}'),
558559
('-m', '--memo'),
@@ -569,7 +570,6 @@ def test_invocation(self):
569570
for args in itertools.product(*choices):
570571
with self.subTest(args=args[1:]):
571572
_ = self.invoke_pickletools(*args)
572-
self.addCleanup(os_helper.unlink, output_file)
573573

574574
with self.assertRaises(SystemExit):
575575
# suppress argparse error message
@@ -579,6 +579,7 @@ def test_invocation(self):
579579
def test_output_flag(self):
580580
# test 'python -m pickletools -o/--output'
581581
output_file = tempfile.mktemp()
582+
self.addCleanup(os_helper.unlink, output_file)
582583
data = ("fake_data",)
583584
expect = '''
584585
0: \\x80 PROTO 5
@@ -601,7 +602,6 @@ def test_output_flag(self):
601602
self.assertListEqual(res.splitlines(), [])
602603
self.assertListEqual(res_from_file.splitlines(),
603604
expect.splitlines())
604-
self.addCleanup(os_helper.unlink, output_file)
605605

606606
def test_memo_flag(self):
607607
# test 'python -m pickletools -m/--memo'

0 commit comments

Comments
 (0)