Add type validation.#2097
Add type validation.#2097nicoddemus merged 1 commit intopytest-dev:masterfrom decentral1se:junitxml-warn
type validation.#2097Conversation
|
Looks good so far!
How about making Something like: def filename(optname, path):
"""Argparse type validator for filename arguments"""
if os.path.isdir(path):
raise UsageError("Must be a filename, given: {0}".format(path))
return pathAnd when registering the option, instead of: type=filename,We use: type=functools.partial(optname='--junitxml'), |
| """ error in pytest usage or invocation""" | ||
|
|
||
|
|
||
| def filename(path): |
There was a problem hiding this comment.
How about naming this something which makes it more explicit that it is a argparse type validator? How about filename_arg or something like this?
|
Oh, |
| 3.0.5.dev0 | ||
| ========== | ||
|
|
||
| * Add Argparse style type validation for ``--confcutdir`` and ``--junit-xml`` (`#2089`_). |
There was a problem hiding this comment.
Perhaps something more user oriented, for example:
* Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories and filenames, respectively (`#2089`_ and `#2078`_). Thanks to `@lwm`_ for the PR.
With this, you can also remove the entry "An error message is now displayed if --confcutdir is not a valid directory..." some items below this one, since it replaces it.
|
Thanks! |
|
🚀 |
|
Unless someone else wants more time to review this, I plan to merge this at the end of the day. 😁 |
|
|
||
|
|
||
| def filename_arg(path, optname): | ||
| """ Argparse type validator for filename arguments. |
There was a problem hiding this comment.
Extra space here.. s/""" A/"""A/.
But also done like this elsewhere. So let's just keep it.
|
@lwm |
Ditto. 😁 👍 |
|
😄 🍷 |
Changes to add to the conversation in #2089.
Something which may not be acceptable is the reduced specificity of the error messages. For example, the validation function
filenamecan't refer to--junit-xmlin the error message.Let me know what you think @nicoddemus.