Skip to content

Commit

Permalink
repozo: prevent an incorrect "option ignored" warning (#404)
Browse files Browse the repository at this point in the history
When running backup or verify, "--with-verify option is ignored"
warning was issued even when this option was not passed
  • Loading branch information
perrinjerome authored Oct 30, 2024
1 parent bcca663 commit 98b3baa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
================
Expand Down
8 changes: 4 additions & 4 deletions src/ZODB/scripts/repozo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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


Expand Down
15 changes: 15 additions & 0 deletions src/ZODB/scripts/tests/test_repozo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -198,13 +199,23 @@ 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
self.assertRaises(SystemExit, repozo.parseargs,
['-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',
Expand All @@ -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',
Expand All @@ -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:
Expand Down

0 comments on commit 98b3baa

Please sign in to comment.