From 86d62717e43e9597aa6f86a25e3be3e74efaea44 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Wed, 13 Dec 2023 23:41:34 +0800 Subject: [PATCH] refactor File.replace_ext --- csst_common/file.py | 2 +- tests/test_file.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/csst_common/file.py b/csst_common/file.py index 6d77d9d..c81b966 100644 --- a/csst_common/file.py +++ b/csst_common/file.py @@ -6,7 +6,7 @@ class File: self.file_path = file_path self.file_path_prefix, self.file_path_ext = os.path.splitext(file_path) - def switch_extension(self, ext="wht.fits") -> str: + def replace_ext(self, ext="wht.fits") -> str: if ext.startswith("."): return self.file_path_prefix + ext else: diff --git a/tests/test_file.py b/tests/test_file.py index 9405578..bc45a2d 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -5,5 +5,5 @@ from csst_common import File class TestFile(unittest.TestCase): def test_parameterized_module_decorator(self): f = File("/path/to/file.fits") - self.assertEqual(f.switch_extension(".cat"), "/path/to/file.cat") - self.assertEqual(f.switch_extension("img.cat"), "/path/to/file_img.cat") + self.assertEqual(f.replace_ext(".cat"), "/path/to/file.cat") + self.assertEqual(f.replace_ext("img.cat"), "/path/to/file_img.cat") -- GitLab