mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-16 15:20:42 +01:00
test-runner: fix --help and unknown options
If --help or unknown options were supplied to test-runner python would thrown a maximum recusion depth exception. This was due to the way ArgumentParser was subclassed. To fix this call ArgumentParser.__init__() rather than using the super() method. And do this also for the RunnerCoreArgParse subclass as well. In addition the namespace argument was removed from parse_args since its not used, and instead supplied directly to the parents parse_args method.
This commit is contained in:
parent
01efa0171d
commit
96e8c0a3ab
@ -82,7 +82,7 @@ class RunnerNamespace(Namespace):
|
|||||||
#
|
#
|
||||||
class RunnerCoreArgParse(ArgumentParser):
|
class RunnerCoreArgParse(ArgumentParser):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(self, *args, **kwargs)
|
ArgumentParser.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
self.add_argument('--start', '-s',
|
self.add_argument('--start', '-s',
|
||||||
help='Custom init process in virtual environment',
|
help='Custom init process in virtual environment',
|
||||||
@ -144,23 +144,23 @@ class RunnerCoreArgParse(ArgumentParser):
|
|||||||
dest='valgrind')
|
dest='valgrind')
|
||||||
|
|
||||||
# Overwrite to use a custom namespace class and parse from env
|
# Overwrite to use a custom namespace class and parse from env
|
||||||
def parse_args(self, *args, namespace=RunnerNamespace()):
|
def parse_args(self, *args):
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
return super().parse_args(*args, namespace=namespace)
|
return super().parse_args(*args, namespace=RunnerNamespace())
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
for k, v in os.environ.items():
|
for k, v in os.environ.items():
|
||||||
options.append('--' + k)
|
options.append('--' + k)
|
||||||
options.append(v)
|
options.append(v)
|
||||||
|
|
||||||
return self.parse_known_args(args=options, namespace=namespace)[0]
|
return self.parse_known_args(args=options, namespace=RunnerNamespace())[0]
|
||||||
|
|
||||||
#
|
#
|
||||||
# Arguments only needed outside the test environment
|
# Arguments only needed outside the test environment
|
||||||
#
|
#
|
||||||
class RunnerArgParse(RunnerCoreArgParse):
|
class RunnerArgParse(RunnerCoreArgParse):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
RunnerCoreArgParse.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
self.add_argument('--runner', '-r',
|
self.add_argument('--runner', '-r',
|
||||||
metavar='<runner type>',
|
metavar='<runner type>',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user