string_function_examples

This script provides several examples of how one can use the test helper package to validate functions that receive or generate string values. The optional runtime arguments below allow the user to select which string examples they would like to run. If no runtime flags are used, this script will run all of the built-in string examples.

Parameters

—run_empty_string_demobool, default False

Boolean flag for whether the empty string example should be run.

—run_single_char_demobool, default False

Boolean flag for whether the single character string example should be run.

—run_multi_char_demobool, default False

Boolean flag for whether the multiple-character string example should be run.

—run_multiply_string_demobool, default False

Boolean flag for whether the multiply string example should be run.

—run_concat_strings_demobool, default False

Boolean flag for whether the concatenate strings example should be run.

—run_remove_vowels_demobool, default False

Boolean flag for whether the remove vowels example should be run.

Module Contents

Functions

return_empty_string

Returns empty string.

return_single_char

Returns single character string (output depends on the value of the DEFAULT_CHAR constant).

return_multi_char_string

Return string with multiple characters (output depends on the value of the DEFAULT_MULTI_CHAR_STR constant).

concat_strings

Returns the concatenation of two strings.

multiply_string

Returns the inputted string multiplied by a requested number of repetitions.

remove_vowels

Returns a copy of the input string with all vowels removed.

Data

DEFAULT_CHAR

Default one-character string.

DEFAULT_MULTI_CHAR_STR

Default multiple-character string.

parser

Parser for optional runtime arguments.

args

Parsed runtime arguments.

run_empty_string_demo

Runtime flag for whether we should run the empty string example.

run_single_char_demo

Runtime flag for whether we should run the single character string example.

run_multi_char_demo

Runtime flag for whether we should run the multiple character string example.

run_multiply_string_demo

Runtime flag for whether we should run the multiply string example.

run_concat_strings_demo

Runtime flag for whether we should run the concatenate strings example.

run_remove_vowels_demo

Runtime flag for whether we should run the remove vowels demo.

any_demos

Boolean for whether any demos were requested by the user (through the runtime arguments).

run_all_demos

Boolean for whether all demos should be run (default behaviour if no specific demos are requested).

API

string_function_examples.DEFAULT_CHAR = 'a'

Default one-character string.

string_function_examples.DEFAULT_MULTI_CHAR_STR = 'abc'

Default multiple-character string.

string_function_examples.parser = 'ArgumentParser(...)'

Parser for optional runtime arguments.

string_function_examples.args = 'parse_args(...)'

Parsed runtime arguments.

string_function_examples.run_empty_string_demo = None

Runtime flag for whether we should run the empty string example.

string_function_examples.run_single_char_demo = None

Runtime flag for whether we should run the single character string example.

string_function_examples.run_multi_char_demo = None

Runtime flag for whether we should run the multiple character string example.

string_function_examples.run_multiply_string_demo = None

Runtime flag for whether we should run the multiply string example.

string_function_examples.run_concat_strings_demo = None

Runtime flag for whether we should run the concatenate strings example.

string_function_examples.run_remove_vowels_demo = None

Runtime flag for whether we should run the remove vowels demo.

string_function_examples.any_demos = None

Boolean for whether any demos were requested by the user (through the runtime arguments).

string_function_examples.run_all_demos = None

Boolean for whether all demos should be run (default behaviour if no specific demos are requested).

string_function_examples.return_empty_string()

Returns empty string.

string_function_examples.return_single_char()

Returns single character string (output depends on the value of the DEFAULT_CHAR constant).

string_function_examples.return_multi_char_string()

Return string with multiple characters (output depends on the value of the DEFAULT_MULTI_CHAR_STR constant).

string_function_examples.concat_strings(str1, str2)

Returns the concatenation of two strings.

string_function_examples.multiply_string(str_to_multiply, num_repeats)

Returns the inputted string multiplied by a requested number of repetitions.

string_function_examples.remove_vowels(str_val)

Returns a copy of the input string with all vowels removed.