webdriver_test_tools.project.cmd.new module¶
-
webdriver_test_tools.project.cmd.new.
main
(test_package_path, test_package, args)[source]¶ Command line dialogs for creating a new file
This method checks
args
for optional arguments for each of its prompts. If these are set to something other thanNone
, their corresponding input prompts will be skipped unless validation for that parameter fails.type
,module_name
, andclass_name
are the 3 values required to create a new file. If these are all set to something other thanNone
, this method will default to an emptydescription
unless one is provided.force
is the only optional parameter that does not have a prompt. It will default toFalse
unless the--force
flag is used when calling this method.The
new page
command has additional optional arguments--prototype
and--yaml
/--no-yaml
(depending on the configuration ofProjectFilesConfig.ENABLE_PAGE_OBJECT_YAML
). Prompt for--prototype
will not be shown iftype
,module_name
, andclass_name
are all set to something other thanNone
. Instead, this method will use the standard page object template unless one is specified withprototype
. Currently there is no prompt for the--yaml
/--no-yaml
arguments, so the value ofProjectFilesConfig.ENABLE_PAGE_OBJECT_YAML
will always be used unless--yaml
/--no-yaml
is specified.- Parameters
test_package_path – The root directory of the test package
test_package – The python package name of the test package
args – Parsed arguments for the
new
command
-
webdriver_test_tools.project.cmd.new.
add_new_subparser
(subparsers, config_module, formatter_class=<class 'argparse.RawTextHelpFormatter'>)[source]¶ Add subparser for the
<test_package> new
command- Parameters
subparsers –
argparse._SubParsersAction
object for the test package ArgumentParser (i.e. the object returned by theadd_subparsers()
method)config_module – The module object for
<test_project>.config
formatter_class – (Default:
argparse.RawTextHelpFormatter
) Class to use for theformatter_class
parameter
- Returns
argparse.ArgumentParser
object for the newly addednew
subparser
-
webdriver_test_tools.project.cmd.new.
get_new_parent_parser
(parents=[], class_name_metavar='<ClassName>', class_name_help='Name to use for the initial class')[source]¶ Returns an
ArgumentParser
with<module_name>
,<class_name>
, and--description
arguments- Parameters
parents – (Optional) List of
ArgumentParser
objects to use as parents for the test argument parserclass_name_metavar – (Optional) Metavar to display for the class_name argument
class_name_help – (Optional) Help text to use for the class_name argument
- Returns
ArgumentParser
with<module_name>
,<class_name>
, and--description
arguments
-
webdriver_test_tools.project.cmd.new.
parse_new_args
(package_name, tests_module, args)[source]¶ Parse arguments and run the ‘new’ command
- Parameters
package_name – Name of the test package
tests_module – The module object for
<test_project>.tests
. Used to determine the filepath of the packageargs – The namespace returned by parser.parse_args()
- Returns
Exit code, 0 if files were created without exceptions, 1 otherwise.
Note
Technically, this will always return 0, as all fail states cause an exception to be raised. This is just to keep it consistent with other project cmd parse arg functions.
-
webdriver_test_tools.project.cmd.new.
validate_description
(description)[source]¶ Replaces double quotes with single quotes in class description
If the description is
None
or an empty string, this function considers it valid and returnsNone
- Parameters
description – The desired description string
- Returns
Validated description string with double quotes replaced with single quotes or
None
if the description is empty