From bd5076ebe65badff038fe086548a881e3d2e0976 Mon Sep 17 00:00:00 2001 From: kim woo seok Date: Sat, 23 Sep 2023 23:32:09 +0900 Subject: [PATCH] Fix repeated unnecessarily 'os.makedirs()' in test_recon_cron.py Return value instead of sys.exit() if an exception occurs RelatedChange: I4ca91e3b519a99f3096b95b286779a183e936eb7 Change-Id: I9ebbf5b9f4216c3eab5ab42a0014a750ca28980b --- swift/cli/recon_cron.py | 4 ++-- test/unit/cli/test_recon_cron.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/swift/cli/recon_cron.py b/swift/cli/recon_cron.py index b7cf3566d5..d2ba80361a 100644 --- a/swift/cli/recon_cron.py +++ b/swift/cli/recon_cron.py @@ -50,7 +50,7 @@ def main(): except Exception: print("Usage: %s CONF_FILE" % sys.argv[0].split('/')[-1]) print("ex: swift-recon-cron /etc/swift/object-server.conf") - sys.exit(1) + return 1 conf = readconf(conf_path, 'filter:recon') device_dir = conf.get('devices', '/srv/node') recon_cache_path = conf.get('recon_cache_path', DEFAULT_RECON_CACHE_PATH) @@ -70,4 +70,4 @@ def main(): msg = 'Exception during recon-cron while accessing devices' logger.exception(msg) print('%s: %s' % (msg, err)) - sys.exit(1) + return 1 diff --git a/test/unit/cli/test_recon_cron.py b/test/unit/cli/test_recon_cron.py index 4a24fd5fc2..8e53d1e0b0 100644 --- a/test/unit/cli/test_recon_cron.py +++ b/test/unit/cli/test_recon_cron.py @@ -32,11 +32,8 @@ class TestReconCron(TestCase): def test_get_async_count(self): device_dir = os.path.join(self.temp_dir, 'device') - os.makedirs(device_dir) device_index = os.path.join(device_dir, '1') - os.makedirs(device_index) async_dir = os.path.join(device_index, ASYNCDIR_BASE) - os.makedirs(async_dir) entry1 = os.path.join(async_dir, 'entry1') entry2 = os.path.join(async_dir, 'entry2') os.makedirs(entry1)