From 0f1af1d991399e4725fd8227561b0de12f0a87f3 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 6 Jul 2023 12:29:49 -0700 Subject: [PATCH] improve filehandle hygene --- tests/test_editblock.py | 4 ++-- tests/test_wholefile.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_editblock.py b/tests/test_editblock.py index 84d061767..82940e3ef 100644 --- a/tests/test_editblock.py +++ b/tests/test_editblock.py @@ -271,7 +271,7 @@ new # Call the run method with a message coder.run(with_message="hi") - content = open(file1, encoding="utf-8").read() + content = Path(file1).read_text(encoding="utf-8") self.assertEqual(content, "one\nnew\nthree\n") def test_full_edit_dry_run(self): @@ -314,7 +314,7 @@ new # Call the run method with a message coder.run(with_message="hi") - content = open(file1, encoding="utf-8").read() + content = Path(file1).read_text(encoding="utf-8") self.assertEqual(content, orig_content) diff --git a/tests/test_wholefile.py b/tests/test_wholefile.py index 7f2dfe385..de85e04c8 100644 --- a/tests/test_wholefile.py +++ b/tests/test_wholefile.py @@ -240,7 +240,7 @@ Do this: # Call the run method with a message coder.run(with_message="hi") - content = open(file1, encoding="utf-8").read() + content = Path(file1).read_text(encoding="utf-8") # check for one trailing newline self.assertEqual(content, new_content + "\n")