From: Phil Sutter Date: Wed, 15 Jul 2026 22:57:56 +0000 (+0200) Subject: tests: py: Fix --keep test runner option X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68086402c28a4934d61fb9fdb796bc811fb045ee;p=thirdparty%2Fnftables.git tests: py: Fix --keep test runner option The boolean flag expected a value, although not used. Set 'action=store_true' to really make it a flag. While at it, simplify the code by eliminating the inverse-value auto_delete helper variable. Fixes: f2b5d6fc26b9a ("tests: py: don't use a fixed filename") Signed-off-by: Phil Sutter --- diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py index 56d4e0fc..4a00ce0c 100755 --- a/tests/py/nft-test.py +++ b/tests/py/nft-test.py @@ -36,7 +36,6 @@ chain_list = [] all_set = dict() obj_list = [] signal_received = 0 -auto_delete = True class Colors: @@ -1523,7 +1522,7 @@ def main(): parser.add_argument('-l', '--library', default=None, help='path to libntables.so.1, overrides --host') - parser.add_argument('-k', '--keep', default=False, + parser.add_argument('-k', '--keep', action='store_true', help='keep log file around after tests') parser.add_argument('-N', '--no-netns', action='store_true', @@ -1577,11 +1576,6 @@ def main(): "You need to build the project." % args.library) return 99 - global auto_delete - - if args.keep: - auto_delete = False - if args.enable_schema and not args.enable_json: print_error("Option --schema requires option --json") return 99 @@ -1593,8 +1587,8 @@ def main(): tests = passed = warnings = errors = 0 global log_file try: - log_file = tempfile.NamedTemporaryFile(prefix="nftables-test-py-", suffix=".log", mode='w', delete=auto_delete) - if auto_delete: + log_file = tempfile.NamedTemporaryFile(prefix="nftables-test-py-", suffix=".log", mode='w', delete = not args.keep) + if not args.keep: print_info("Log file %s will not be retained. Pass -k to keep it." % log_file.name) else: print_info("Log will be available at %s" % log_file.name)