From 98b3baa926a41407876267437a873667564a3f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Wed, 30 Oct 2024 14:44:52 +0900 Subject: [PATCH] repozo: prevent an incorrect "option ignored" warning (#404) When running backup or verify, "--with-verify option is ignored" warning was issued even when this option was not passed --- CHANGES.rst | 2 ++ src/ZODB/scripts/repozo.py | 8 ++++---- src/ZODB/scripts/tests/test_repozo.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 840bd7355..668d55655 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ 6.0.1 (unreleased) ================== + - repozo: prevent an incorrect "option ignored" warning when running backup or verify. + 6.0 (2024-03-20) ================ diff --git a/src/ZODB/scripts/repozo.py b/src/ZODB/scripts/repozo.py index aa7b82490..083a8c293 100755 --- a/src/ZODB/scripts/repozo.py +++ b/src/ZODB/scripts/repozo.py @@ -249,9 +249,9 @@ class Options: if options.output is not None: log('--output option is ignored in backup mode') options.output = None - if options.withverify is not None: + if options.withverify: log('--with-verify option is ignored in backup mode') - options.withverify = None + options.withverify = False if not options.file: usage(1, '--file is required in backup mode') elif options.mode == RECOVER: @@ -281,9 +281,9 @@ class Options: if options.killold: log('--kill-old-on-full option is ignored in verify mode') options.killold = False - if options.withverify is not None: + if options.withverify: log('--with-verify option is ignored in verify mode') - options.withverify = None + options.withverify = False return options diff --git a/src/ZODB/scripts/tests/test_repozo.py b/src/ZODB/scripts/tests/test_repozo.py index f19c81703..13d24bef5 100644 --- a/src/ZODB/scripts/tests/test_repozo.py +++ b/src/ZODB/scripts/tests/test_repozo.py @@ -189,6 +189,7 @@ def test_repo_is_required(self): def test_backup_ignored_args(self): from ZODB.scripts import repozo options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-v', + '--with-verify', '-f', '/tmp/Data.fs', '-o', '/tmp/ignored.fs', '-D', '2011-12-13']) @@ -198,6 +199,10 @@ def test_backup_ignored_args(self): self.assertEqual(options.output, None) self.assertIn('--output option is ignored in backup mode', sys.stderr.getvalue()) + self.assertEqual(options.withverify, False) + self.assertIn( + '--with-verify option is ignored in backup mode', + sys.stderr.getvalue()) def test_backup_required_args(self): from ZODB.scripts import repozo @@ -205,6 +210,12 @@ def test_backup_required_args(self): ['-B', '-r', '/tmp/nosuchdir']) self.assertIn('--file is required', sys.stderr.getvalue()) + def test_backup_no_ignored_args_warning(self): + from ZODB.scripts import repozo + repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-v', + '-f', '/tmp/Data.fs',]) + self.assertNotIn('option is ignored', sys.stderr.getvalue()) + def test_recover_ignored_args(self): from ZODB.scripts import repozo options = repozo.parseargs(['-R', '-r', '/tmp/nosuchdir', '-v', @@ -220,6 +231,7 @@ def test_recover_ignored_args(self): def test_verify_ignored_args(self): from ZODB.scripts import repozo options = repozo.parseargs(['-V', '-r', '/tmp/nosuchdir', '-v', + '--with-verify', '-o', '/tmp/ignored.fs', '-D', '2011-12-13', '-f', '/tmp/ignored.fs', @@ -242,6 +254,9 @@ def test_verify_ignored_args(self): self.assertEqual(options.killold, False) self.assertIn('--kill-old-on-full option is ignored in verify mode', sys.stderr.getvalue()) + self.assertEqual(options.withverify, False) + self.assertIn('--with-verify option is ignored in verify mode', + sys.stderr.getvalue()) class FileopsBase: