From bdf5712b0111e8b6e60bc1ef747bff234fff5fda Mon Sep 17 00:00:00 2001 From: Will Barton Date: Mon, 21 Oct 2024 08:32:35 -0400 Subject: [PATCH] Fix SIM115 by using a context manager Ruff started throwing a SIM115 error: ``` cfgov/v1/tests/management/commands/test_publish_pages.py:33:14: SIM115 Use a context manager for opening files ``` This fixes that by using a context management. --- cfgov/v1/tests/management/commands/test_publish_pages.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cfgov/v1/tests/management/commands/test_publish_pages.py b/cfgov/v1/tests/management/commands/test_publish_pages.py index 50049d01b02..5981a5c793d 100644 --- a/cfgov/v1/tests/management/commands/test_publish_pages.py +++ b/cfgov/v1/tests/management/commands/test_publish_pages.py @@ -30,10 +30,10 @@ def make_page_with_draft_revision(self, slug): @contextmanager def make_tempfile(self, content): - tf = tempfile.NamedTemporaryFile() - tf.write(content) - tf.seek(0) - yield tf + with tempfile.NamedTemporaryFile() as tf: + tf.write(content) + tf.seek(0) + yield tf def test_dry_run(self): with self.make_tempfile(b"/a/\n/b/\n/c/\n") as tf: