summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2013-09-26 16:44:37 +0200
committerMartin Kosek <mkosek@redhat.com>2013-10-04 10:25:31 +0200
commit2d6c7e3adb47787ba7c38c303fd1f528f7d52a13 (patch)
treea6e8355664e6c17c109467ff8a8da75843d9dd38
parent0b29bfde0df92ed0a61b5ce099295c0b0c6495d4 (diff)
downloadfreeipa-2d6c7e3adb47787ba7c38c303fd1f528f7d52a13.tar.gz
freeipa-2d6c7e3adb47787ba7c38c303fd1f528f7d52a13.tar.xz
freeipa-2d6c7e3adb47787ba7c38c303fd1f528f7d52a13.zip
frontend: report arguments errors with better detail
When reporting argument errors, show also a context -- what is processed, what is the name of the command.
-rw-r--r--ipalib/frontend.py3
-rw-r--r--ipatests/test_ipalib/test_frontend.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index cac3e3b3..f478ef09 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -869,7 +869,8 @@ class Command(HasParam):
for arg in args():
if optional and arg.required:
raise ValueError(
- '%s: required argument after optional' % arg.name
+ '%s: required argument after optional in %s arguments %s' % (arg.name,
+ self.name, map(lambda x: x.param_spec, args()))
)
if multivalue:
raise ValueError(
diff --git a/ipatests/test_ipalib/test_frontend.py b/ipatests/test_ipalib/test_frontend.py
index 310d7a53..ce943a7e 100644
--- a/ipatests/test_ipalib/test_frontend.py
+++ b/ipatests/test_ipalib/test_frontend.py
@@ -280,7 +280,7 @@ class test_Command(ClassChecker):
# Test ValueError, required after optional:
e = raises(ValueError, self.get_instance, args=('arg1?', 'arg2'))
- assert str(e) == 'arg2: required argument after optional'
+ assert str(e) == "arg2: required argument after optional in %s arguments ['arg1?', 'arg2']" % (self.get_instance().name)
# Test ValueError, scalar after multivalue:
e = raises(ValueError, self.get_instance, args=('arg1+', 'arg2'))