| 1 |
From: Bjoern Ricks <[email protected]> |
| 2 |
Date: Fri, 9 Jan 2026 11:28:53 +0100 |
| 3 |
Subject: [PATCH] test: Fix argument parser tests on Python 3.14 |
| 4 |
|
| 5 |
Origin: https://github.com/greenbone/greenbone-feed-sync/commit/4170b0d4692993f858c73b9e17744e520f6d6669 |
| 6 |
|
| 7 |
In Python 3.14 the way the program name is parsed in the argparser |
| 8 |
module has changed. See https://github.com/python/cpython/issues/66436 |
| 9 |
for details. Therefore the tests did break which mock the pre 3.14 |
| 10 |
parsing of the program name. Fix this behavior by explicitly passing a |
| 11 |
program name derived from `sys.argv[0]` (which is the default behavior |
| 12 |
in Python < 3.14). Despite failing tests this had no influence of the |
| 13 |
tool. |
| 14 |
|
| 15 |
Fixes #325 |
| 16 |
--- |
| 17 |
greenbone/feed/sync/parser.py | 3 ++- |
| 18 |
1 file changed, 2 insertions(+), 1 deletion(-) |
| 19 |
|
| 20 |
diff --git a/greenbone/feed/sync/parser.py b/greenbone/feed/sync/parser.py |
| 21 |
index 05a4239..d236a70 100644 |
| 22 |
--- a/greenbone/feed/sync/parser.py |
| 23 |
+++ b/greenbone/feed/sync/parser.py |
| 24 |
@@ -3,6 +3,7 @@ |
| 25 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 26 |
# |
| 27 |
|
| 28 |
+import sys |
| 29 |
from argparse import ArgumentParser, Namespace |
| 30 |
from pathlib import Path |
| 31 |
from typing import Any, Optional, Sequence |
| 32 |
@@ -49,7 +50,7 @@ class CliParser: |
| 33 |
""" |
| 34 |
|
| 35 |
def __init__(self) -> None: |
| 36 |
- parser = ArgumentParser(add_help=False) |
| 37 |
+ parser = ArgumentParser(prog=Path(sys.argv[0]).name, add_help=False) |
| 38 |
shtab.add_argument_to(parser) |
| 39 |
parser.add_argument( |
| 40 |
"--version", |