API Documentation¶
exceptions module¶
-
exception
selenium_generator.base.exceptions.InvalidConfiguration(errors)¶ Bases:
ExceptionException is raised when configuration doesn’t match its schema.
Parameters: errors ( cerberus.errors.ErrorList) – List of allowed drivers-
__init__(errors)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
selenium_generator.base.exceptions.InvalidScenario(errors)¶ Bases:
ExceptionException is raised when scenario doesn’t match its schema.
Parameters: errors ( cerberus.errors.ErrorList) – List of allowed drivers-
__init__(errors)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
selenium_generator.base.exceptions.MissingDriverConfiguration(driver)¶ Bases:
ExceptionException is raised when in test scenario there is specified driver which is not configured in configuration.
Parameters: driver (str) – Name of a driver whose configuration is missing -
__init__(driver)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
selenium_generator.base.exceptions.UnsupportedDriver(allowed_drivers)¶ Bases:
ValueErrorException is raised when in configuration there is configured local driver which is not supported.
Parameters: allowed_drivers (list(str)) – List of allowed drivers -
__init__(allowed_drivers)¶ Initialize self. See help(type(self)) for accurate signature.
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
singleton module¶
-
selenium_generator.base.singleton.__instances= {}¶ List of class instances created with singleton decorator.
-
selenium_generator.base.singleton.singleton(cls)¶ Decorator for singleton design pattern. Function decorates a class and stores its instance to a list of instances from which is later returned if the class is called again.
Parameters: cls – Decorated class Returns: Instance of a decorated class
file_manager module¶
-
class
selenium_generator.base.file_manager.FileManager¶ Bases:
objectClass for file manipulation.
-
__init__¶ Initialize self. See help(type(self)) for accurate signature.
-
static
file_exists(path)¶ Method checks if file of a given path exists.
Parameters: path (str) – Path of a file to check Returns: Instance of Remote driver.
-
static
get_list_of_files(dir_path)¶ Methods load all files from given directory and its subdirectories recursively.
Parameters: dir_path (str) – Path to a dir to load files from Returns: List of all loaded files Return type: list(str)
-
static
load_json(file)¶ Method parses json file into Python dict
Returns: Parsed json file Return type: dict
-
static
load_yaml(file)¶ Method parses yaml file into Python dict
Returns: Parsed yaml file Return type: dict
-
static
mkdir(path, parents=True, exists_ok=True)¶ Method creates dir of a given path
Parameters: - path (str) – Path to a dir
- parents (bool) – Create all subdirectories recursively
- exists_ok (bool) – Firstly checks if dir is already exists
-
static
remove_tree(path)¶ Methods deletes file/directory and its subdirectories of a given path.
Parameters: path (str) – Path to a file/dir
-
base_driver module¶
-
class
selenium_generator.factories.drivers.base_driver.BaseDriver(driver_name, params)¶ Bases:
objectClass Base Driver.
Parameters: - driver_name (str) – Driver name.
- params (dict) – Parameters of a driver from configuration.
-
driver_name¶ Driver name.
Type: str
-
url¶ URL of a remote driver.
Type: str
-
version¶ Version of a local driver.
Type: str
-
options¶ Driver Options from configuration.
Type: list(str)
-
desired_caps¶ Desired capabilities from configuration.
Type: dict
-
REMOTE= None¶ Class attribute for determination of a type of a driver [True - remote, False - local]
Type: bool
-
__init__(driver_name, params)¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
check_type(driver_type)¶ Method check if type of driver corresponds with a given type in args.
Parameters: driver_type (str) – Type of a driver to check. Returns: True if corresponds, False otherwise. Return type: bool
-
selenium_generator.factories.drivers.base_driver.DEFAULT_EXECUTOR= 'http://127.0.0.1:4444/wd/hub'¶ URL of a default executor for running tests on remote machine
driver_factory module¶
-
class
selenium_generator.factories.drivers.driver_factory.DriverFactory¶ Class creates instance of Selenium WebDriver for specified driver.
Parameters: - driver_classes (list(BaseDriver)) – List of classes for running individual types of drivers.
- allowed_local_drivers (str) – List of names of allowed local drivers.
-
driver_classes¶ List of classes for running individual types of drivers.
Type: list(BaseDriver)
-
allowed_local_drivers¶ List of names of allowed local drivers.
Type: str
-
drivers¶ Loaded drivers object from configuration.
Type: dict
-
_verify_drivers(driver_name)¶ - Method verify if local driver is allowed in allowed_local_drivers and if any type of driver is configured in
- configuration.
Parameters: driver_name (str) – Name of a driver.
Raises: UnsupportedDriver– If driver_name is not in allowed_local_drivers.MissingDriverConfiguration– If configuration of a driver is missing in configuration.
-
run(driver_name)¶ Method create instance of required webdriver based on driver_name and its configuration.
Parameters: driver_name (str) – Name of a driver. Returns: Instance of a required webdriver. Return type: Webdriver
-
selenium_generator.factories.drivers.driver_factory.DEFAULT_DRIVER_CLASSES= [<class 'selenium_generator.factories.drivers.local_driver.LocalDriver'>, <class 'selenium_generator.factories.drivers.remote_driver.RemoteDriver'>]¶ List of class which
DriverFactoryuses for creating of required driver.
-
selenium_generator.factories.drivers.driver_factory.DEFAULT_LOCAL_DRIVERS= ['chrome', 'firefox']¶ List of names of allowed local drivers. In other words driver which are by default supported with
selenium_generator.factories.drivers.local_driver.LocalDriver
-
selenium_generator.factories.drivers.driver_factory.DriverFactory(driver_classes=[<class 'selenium_generator.factories.drivers.local_driver.LocalDriver'>, <class 'selenium_generator.factories.drivers.remote_driver.RemoteDriver'>], allowed_local_drivers=['chrome', 'firefox']) Class creates instance of Selenium WebDriver for specified driver.
Parameters: - driver_classes (list(BaseDriver)) – List of classes for running individual types of drivers.
- allowed_local_drivers (str) – List of names of allowed local drivers.
-
selenium_generator.factories.drivers.driver_factory.driver_classes¶ List of classes for running individual types of drivers.
Type: list(BaseDriver)
-
selenium_generator.factories.drivers.driver_factory.allowed_local_drivers¶ List of names of allowed local drivers.
Type: str
-
selenium_generator.factories.drivers.driver_factory.drivers¶ Loaded drivers object from configuration.
Type: dict
local_driver module¶
-
class
selenium_generator.factories.drivers.local_driver.LocalDriver(driver_name, params)¶ Bases:
selenium_generator.factories.drivers.base_driver.BaseDriver-
REMOTE= False¶ Class attribute signifies that class is for local driver
-
__init__(driver_name, params)¶ Initialize self. See help(type(self)) for accurate signature.
-
_add_option(options)¶ Method adds items to instance of Options for the required driver from configuration.
Parameters: options – Instance of Options class for required browser
-
_run_chrome()¶ Method runs instance of driver for Chrome.
Returns: Instance of driver for Chrome.
-
_run_firefox()¶ Method runs instance of driver for Firefox.
Returns: Instance of driver for Firefox.
-
classmethod
check_type(driver_type)¶ Method check if type of driver corresponds with a given type in args.
Parameters: driver_type (str) – Type of a driver to check. Returns: True if corresponds, False otherwise. Return type: bool
-
run()¶ Method calls individual method for running specific driver based on driver name.
Returns: Instance of required driver.
-
remote_driver module¶
-
class
selenium_generator.factories.drivers.remote_driver.RemoteDriver(driver_name, params)¶ Bases:
selenium_generator.factories.drivers.base_driver.BaseDriver-
REMOTE= False¶ Class attribute signifies that class is for remote driver
-
__init__(driver_name, params)¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
check_type(driver_type)¶ Method check if type of driver corresponds with a given type in args.
Parameters: driver_type (str) – Type of a driver to check. Returns: True if corresponds, False otherwise. Return type: bool
-
run()¶ Method runs instance of Remote WebDriver.
Returns: Instance of Remote driver.
-
base_test module¶
-
class
selenium_generator.factories.tests.base_test.BaseTest(methodName='runTest')¶ Bases:
unittest.case.TestCaseBase class for generating of tests.
-
__init__(methodName='runTest')¶ Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
-
_baseAssertEqual(first, second, msg=None)¶ The default assertEqual implementation, not type specific.
-
_formatMessage(msg, standardMsg)¶ Honour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert
If longMessage is True: * Use the standard message * If an explicit message is provided, plus ‘ : ‘ and the explicit message
-
_getAssertEqualityFunc(first, second)¶ Get a detailed comparison function for the types of the two args.
Returns: A callable accepting (first, second, msg=None) that will raise a failure exception if first != second with a useful human readable error message for those types.
-
_screen_shot_on_error()¶ Take and save a screen shot of the driver page on fail.
-
addCleanup(function, *args, **kwargs)¶ Add a function, with arguments, to be called when the test is completed. Functions added are called on a LIFO basis and are called after tearDown on test failure or success.
Cleanup items are called even if setUp fails (unlike tearDown).
-
addTypeEqualityFunc(typeobj, function)¶ Add a type specific assertEqual style function to compare a type.
This method is for use by TestCase subclasses that need to register their own type equality functions to provide nicer error messages.
Parameters: - typeobj – The data type to call this function on when both values are of the same type in assertEqual().
- function – The callable taking two arguments and an optional msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.
-
assertAlmostEqual(first, second, places=None, msg=None, delta=None)¶ Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.
Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
If the two objects compare equal then they will automatically compare almost equal.
-
assertCountEqual(first, second, msg=None)¶ An unordered sequence comparison asserting that the same elements, regardless of order. If the same element occurs more than once, it verifies that the elements occur the same number of times.
- self.assertEqual(Counter(list(first)),
- Counter(list(second)))
- Example:
- [0, 1, 1] and [1, 0, 1] compare equal.
- [0, 0, 1] and [0, 1] compare unequal.
-
assertDictContainsSubset(subset, dictionary, msg=None)¶ Checks whether dictionary is a superset of subset.
-
assertEqual(first, second, msg=None)¶ Fail if the two objects are unequal as determined by the ‘==’ operator.
-
assertFalse(expr, msg=None)¶ Check that the expression is false.
-
assertGreater(a, b, msg=None)¶ Just like self.assertTrue(a > b), but with a nicer default message.
-
assertGreaterEqual(a, b, msg=None)¶ Just like self.assertTrue(a >= b), but with a nicer default message.
-
assertIn(member, container, msg=None)¶ Just like self.assertTrue(a in b), but with a nicer default message.
-
assertIs(expr1, expr2, msg=None)¶ Just like self.assertTrue(a is b), but with a nicer default message.
-
assertIsInstance(obj, cls, msg=None)¶ Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.
-
assertIsNone(obj, msg=None)¶ Same as self.assertTrue(obj is None), with a nicer default message.
-
assertIsNot(expr1, expr2, msg=None)¶ Just like self.assertTrue(a is not b), but with a nicer default message.
-
assertIsNotNone(obj, msg=None)¶ Included for symmetry with assertIsNone.
-
assertLess(a, b, msg=None)¶ Just like self.assertTrue(a < b), but with a nicer default message.
-
assertLessEqual(a, b, msg=None)¶ Just like self.assertTrue(a <= b), but with a nicer default message.
-
assertListEqual(list1, list2, msg=None)¶ A list-specific equality assertion.
Parameters: - list1 – The first list to compare.
- list2 – The second list to compare.
- msg – Optional message to use on failure instead of a list of differences.
-
assertLogs(logger=None, level=None)¶ Fail unless a log message of level level or higher is emitted on logger_name or its children. If omitted, level defaults to INFO and logger defaults to the root logger.
This method must be used as a context manager, and will yield a recording object with two attributes: output and records. At the end of the context manager, the output attribute will be a list of the matching formatted log messages and the records attribute will be a list of the corresponding LogRecord objects.
Example:
with self.assertLogs('foo', level='INFO') as cm: logging.getLogger('foo').info('first message') logging.getLogger('foo.bar').error('second message') self.assertEqual(cm.output, ['INFO:foo:first message', 'ERROR:foo.bar:second message'])
-
assertMultiLineEqual(first, second, msg=None)¶ Assert that two multi-line strings are equal.
-
assertNotAlmostEqual(first, second, places=None, msg=None, delta=None)¶ Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.
Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
Objects that are equal automatically fail.
-
assertNotEqual(first, second, msg=None)¶ Fail if the two objects are equal as determined by the ‘!=’ operator.
-
assertNotIn(member, container, msg=None)¶ Just like self.assertTrue(a not in b), but with a nicer default message.
-
assertNotIsInstance(obj, cls, msg=None)¶ Included for symmetry with assertIsInstance.
-
assertNotRegex(text, unexpected_regex, msg=None)¶ Fail the test if the text matches the regular expression.
-
assertRaises(expected_exception, *args, **kwargs)¶ Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.
If called with the callable and arguments omitted, will return a context object used like this:
with self.assertRaises(SomeException): do_something()
An optional keyword argument ‘msg’ can be provided when assertRaises is used as a context object.
The context manager keeps a reference to the exception as the ‘exception’ attribute. This allows you to inspect the exception after the assertion:
with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exception self.assertEqual(the_exception.error_code, 3)
-
assertRaisesRegex(expected_exception, expected_regex, *args, **kwargs)¶ Asserts that the message in a raised exception matches a regex.
Parameters: - expected_exception – Exception class expected to be raised.
- expected_regex – Regex (re.Pattern object or string) expected to be found in error message.
- args – Function to be called and extra positional args.
- kwargs – Extra kwargs.
- msg – Optional message used in case of failure. Can only be used when assertRaisesRegex is used as a context manager.
-
assertRegex(text, expected_regex, msg=None)¶ Fail the test unless the text matches the regular expression.
-
assertSequenceEqual(seq1, seq2, msg=None, seq_type=None)¶ An equality assertion for ordered sequences (like lists and tuples).
For the purposes of this function, a valid ordered sequence type is one which can be indexed, has a length, and has an equality operator.
Parameters: - seq1 – The first sequence to compare.
- seq2 – The second sequence to compare.
- seq_type – The expected datatype of the sequences, or None if no datatype should be enforced.
- msg – Optional message to use on failure instead of a list of differences.
-
assertSetEqual(set1, set2, msg=None)¶ A set-specific equality assertion.
Parameters: - set1 – The first set to compare.
- set2 – The second set to compare.
- msg – Optional message to use on failure instead of a list of differences.
assertSetEqual uses ducktyping to support different types of sets, and is optimized for sets specifically (parameters must support a difference method).
-
assertTrue(expr, msg=None)¶ Check that the expression is true.
-
assertTupleEqual(tuple1, tuple2, msg=None)¶ A tuple-specific equality assertion.
Parameters: - tuple1 – The first tuple to compare.
- tuple2 – The second tuple to compare.
- msg – Optional message to use on failure instead of a list of differences.
-
assertWarns(expected_warning, *args, **kwargs)¶ Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.
If called with the callable and arguments omitted, will return a context object used like this:
with self.assertWarns(SomeWarning): do_something()
An optional keyword argument ‘msg’ can be provided when assertWarns is used as a context object.
The context manager keeps a reference to the first matching warning as the ‘warning’ attribute; similarly, the ‘filename’ and ‘lineno’ attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:
with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147)
-
assertWarnsRegex(expected_warning, expected_regex, *args, **kwargs)¶ Asserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches.
Parameters: - expected_warning – Warning class expected to be triggered.
- expected_regex – Regex (re.Pattern object or string) expected to be found in error message.
- args – Function to be called and extra positional args.
- kwargs – Extra kwargs.
- msg – Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager.
-
base_method(**data)¶ Base class for generating of tests.
-
debug()¶ Run the test without collecting errors in a TestResult
-
doCleanups()¶ Execute all cleanup functions. Normally called for you after tearDown.
-
fail(msg=None)¶ Fail immediately, with the given message.
-
failureException¶ alias of
builtins.AssertionError
-
setUp()¶ Base class for generating of tests.
-
classmethod
setUpClass()¶ Base class for generating of tests.
-
shortDescription()¶ Returns a one-line description of the test, or None if no description has been provided.
The default implementation of this method returns the first line of the specified test method’s docstring.
-
skipTest(reason)¶ Skip this test.
-
subTest(msg=<object object>, **params)¶ Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.
-
tearDown()¶ Base class for generating of tests.
-
classmethod
tearDownClass()¶ Base class for generating of tests.
-
test_factory module¶
page_factory module¶
event_handler module¶
keywords module¶
-
class
selenium_generator.handlers.keywords.Keywords¶ Bases:
objectClass stores all keywords which can be used in test scenario and its implementation.
-
pages¶ Module with all Page Objects loaded from directory specified in configuration
Type: module
-
data¶ Test data
Type: dict
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
_close_driver(*args, **kwargs)¶ Method close instance of a driver
-
_maximize(*args, **kwargs)¶ Method maximizes window of a driver
-
_page_object(command)¶ Method executes required method of a given Page Object and parse data in it.
Parameters: command (dict) – Parameters for Page Object to be used based of configuration structure
-
_run_driver(command)¶ Method initializes instance of required driver.
Parameters: command (str) – Name of a driver to be used
-
-
class
selenium_generator.handlers.keywords.MethodExecutor¶ Bases:
objectClass executes method of a required class with given data based on a type of data specification
-
__init__¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
_call_method(class_instance, method, arguments=None, data=None)¶ Method for calling given method based on the given parameters.
Parameters: - class_instance –
- method –
- arguments (dict) – Arguments of a method to be called
- data (dict) – Test data
-
classmethod
_feed_params(arguments, data)¶ Method feeds method with given data based on method arguments.
Parameters: - arguments (dict) – Arguments of a method to be called
- data (dict) – Test data
-
classmethod
execute_method(class_instance, method, params, data)¶ The main method of a class. Gets arguments of a method to be run and calls method for calling itself with the right parameters.
Parameters: - class_instance –
- method –
- params (dict) – Data from params in scenario step
- data (dict) – Data from DDT
-
arg_parser module¶
config_parser module¶
loader module¶
-
class
selenium_generator.test_runner.loader.Loader¶ Bases:
objectClass for loading scenarios.
-
tests¶ Type: list( unittest.TestCase)
-
scenarios¶ Type: list(str)
Type: list(str)
-
test_creator¶ Type: TestFactory
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
Method checks if scenario contains any of tags from configuration
Parameters: scenario (dict) – Parsed scenario Returns: True - scenario contains tag, False - scenario doesn’t contain tag Return type: bool
-
load_scenarios()¶ Methods parses each scenario, checks it and adds them into test suite
Returns: Test suite created for loaded valid scenarios Return type: unittest.TestSuite
-
test_runner module¶
This module implements classes needed for test execution.
-
class
selenium_generator.test_runner.runner.Result(stream, descriptions, verbosity)¶ Bases:
HtmlTestRunner.result.HtmlTestResultResult class.
Parameters: - stream –
- descriptions –
- verbosity –
-
__init__(stream, descriptions, verbosity)¶ Initialize self. See help(type(self)) for accurate signature.
-
_create_test_info(test, err)¶ Creates test info.
Parameters: - test –
- err –
-
_exc_info_to_string(err, test)¶ Converts a sys.exc_info()-style tuple of values into a string.
-
static
_format_duration(elapsed_time)¶ Format the elapsed time in seconds, or milliseconds if the duration is less than 1 second.
-
_get_info_by_testcase()¶ Organize test results by TestCase module.
-
_get_report_summaries(all_results, testRunner)¶ Generate headers and summaries for all given test cases.
-
_prepare_callback(test_info, target_list, verbose_str, short_str)¶ Appends a ‘info class’ to the given target list and sets a callback method to be called by stopTest method.
-
addError(test, err)¶ Called when a test method raises an error.
Parameters: - test –
- err –
-
addExpectedFailure(test, err)¶ Called when an expected failure/error occurred.
-
addFailure(test, err)¶ Called when a test method fails.
Parameters: - test –
- err –
-
addSkip(test, reason)¶ ” Called when a test method was skipped.
-
addSubTest(testcase, test, err)¶ Called when a subTest completes.
-
addSuccess(test)¶ Called when a test executes successfully.
-
addUnexpectedSuccess(test)¶ Called when a test was expected to fail, but succeed.
-
generate_file(testRunner, report_name, report)¶ Generate the report file in the given path.
-
generate_reports(testRunner)¶ Generate report(s) for all given test cases that have been run.
-
getDescription(test)¶ Return the test description if not have test name.
-
get_results_summary(tests)¶ Create a summary of the outcomes of all given tests.
-
printErrorList(flavour, errors)¶ Writes information about the FAIL or ERROR to the stream.
-
printErrors()¶ Called by TestRunner after test run
-
startTest(test)¶ Called before execute each method.
-
startTestRun()¶ Called once before any tests are executed.
See startTest for a method called before each test.
-
stop()¶ Indicates that the tests should be aborted.
-
stopTest(test)¶ Called after excute each test method.
-
stopTestRun()¶ Called once after all tests are executed.
See stopTest for a method called after each test.
-
wasSuccessful()¶ Tells whether or not this result was a success.
-
class
selenium_generator.test_runner.runner.Runner(output='./reports/', report_title='Test results', report_name='TestReport', template='/home/docs/checkouts/readthedocs.org/user_builds/selenium-generator/checkouts/release-0.2/selenium_generator/test_runner/template/report_template.html', resultclass=<class 'selenium_generator.test_runner.runner.Result'>, combine_reports=True)¶ Bases:
HtmlTestRunner.runner.HTMLTestRunnerClass for running test scenarios.
Parameters: - output (str) – Path to folder for storing test report
- report_title (str) – Title of a generated test report
- report_name (str) – Name of a html file with test report
- template (str) – Path to file with test report template
- resultclass (Result) – Test result class
- combine_reports (boolean) – Defines of test report of individual test classes should be combined
-
__init__(output='./reports/', report_title='Test results', report_name='TestReport', template='/home/docs/checkouts/readthedocs.org/user_builds/selenium-generator/checkouts/release-0.2/selenium_generator/test_runner/template/report_template.html', resultclass=<class 'selenium_generator.test_runner.runner.Result'>, combine_reports=True)¶ Construct a TextTestRunner.
Subclasses should accept **kwargs to ensure compatibility as the interface changes.
-
_make_result()¶ Create a TestResult object which will be used to store information about the executed tests.
-
resultclass¶ alias of
unittest.runner.TextTestResult
-
run(test)¶ Runs the given testcase or testsuite.
-
class
selenium_generator.test_runner.runner.TestInfo(test_result, test_method, outcome=0, err=None, sub_test=None, screen_shot=None)¶ Bases:
HtmlTestRunner.result._TestInfoTestInfo class.
Parameters: - test_result (Result) – Test result class
- test_method –
- outcome –
- err –
- sub_test –
- screen_shot – Path to screen shot of a failed test
-
__init__(test_result, test_method, outcome=0, err=None, sub_test=None, screen_shot=None)¶ Initialize self. See help(type(self)) for accurate signature.
validator module¶
-
class
selenium_generator.validators.validator.ExtendedValidator(*args, **kwargs)¶ Bases:
cerberus.validator.ValidatorClass extends Validator class from Cerberus framework
cerberus.Validator-
_BareValidator__store_config(args, kwargs)¶ Assign args to kwargs and store configuration.
-
_BareValidator__validate_definitions(definitions, field)¶ Validate a field’s value against its defined rules.
-
_BareValidator__validate_logical(operator, definitions, field, value)¶ Validates value against all definitions and logs errors according to the operator.
-
_BareValidator__validate_required_fields(document)¶ Validates that required fields are not missing.
Parameters: document – The document being validated.
-
__init__(*args, **kwargs)¶ The arguments will be treated as with this signature:
- __init__(self, schema=None, ignore_none_values=False,
- allow_unknown=False, require_all=False, purge_unknown=False, purge_readonly=False, error_handler=errors.BasicErrorHandler)
-
_drop_nodes_from_errorpaths(_errors, dp_items, sp_items)¶ - Removes nodes by index from an errorpath, relatively to the
- basepaths of self.
Parameters: - errors – A list of
errors.ValidationErrorinstances. - dp_items – A list of integers, pointing at the nodes to drop from
the
document_path. - sp_items – Alike
dp_items, but forschema_path.
-
_drop_remaining_rules(*rules)¶ Drops rules from the queue of the rules that still need to be evaluated for the currently processed field. If no arguments are given, the whole queue is emptied.
-
_error(*args)¶ Creates and adds one or multiple errors.
Parameters: args – Accepts different argument’s signatures.
1. Bulk addition of errors:
- iterable of
ValidationError-instances
The errors will be added to
_errors.2. Custom error:
- the invalid field’s name
- the error message
A custom error containing the message will be created and added to
_errors. There will however be fewer information contained in the error (no reference to the violated rule and its constraint).3. Defined error:
- the invalid field’s name
- the error-reference, see
cerberus.errors - arbitrary, supplemental information about the error
A
ValidationErrorinstance will be created and added to_errors.- iterable of
-
_get_child_validator(document_crumb=None, schema_crumb=None, **kwargs)¶ - Creates a new instance of Validator-(sub-)class. All initial
- parameters of the parent are passed to the initialization, unless a parameter is given as an explicit keyword-parameter.
Parameters: - document_crumb (
tupleor hashable) – Extends thedocument_pathof the child-validator. - schema_crumb (
tupleor hashable) – Extends theschema_pathof the child-validator. - kwargs (
dict) – Overriding keyword-arguments for initialization.
Returns: an instance of
self.__class__
-
_is_normalized¶ Trueif the document is already normalized.
-
_lookup_field(path)¶ - Searches for a field as defined by path. This method is used by the
dependencyevaluation logic.
Parameters: path ( str) – Path elements are separated by a.. A leading^indicates that the path relates to the document root, otherwise it relates to the currently evaluated document, which is possibly a subdocument. The sequence^^at the start will be interpreted as a literal^.Returns: Either the found field name and its value or Nonefor both.Return type: A two-value tuple.
-
_normalize_coerce(mapping, schema)¶ {‘oneof’: [ {‘type’: ‘callable’}, {‘type’: ‘list’,
- ‘schema’: {‘oneof’: [{‘type’: ‘callable’},
- {‘type’: ‘string’}]}},
{‘type’: ‘string’} ]}
-
_normalize_default(mapping, schema, field)¶ {‘nullable’: True}
-
_normalize_default_setter(mapping, schema, field)¶ {‘oneof’: [ {‘type’: ‘callable’}, {‘type’: ‘string’} ]}
-
static
_normalize_purge_unknown(mapping, schema)¶ {‘type’: ‘boolean’}
-
_normalize_rename(mapping, schema, field)¶ {‘type’: ‘hashable’}
-
_normalize_rename_handler(mapping, schema, field)¶ {‘oneof’: [ {‘type’: ‘callable’}, {‘type’: ‘list’,
- ‘schema’: {‘oneof’: [{‘type’: ‘callable’},
- {‘type’: ‘string’}]}},
{‘type’: ‘string’} ]}
-
_validate_allof(definitions, field, value)¶ {‘type’: ‘list’, ‘logical’: ‘allof’}
-
_validate_allow_unknown(constraint, field, value)¶ {‘oneof’: [{‘type’: ‘boolean’}, {‘type’: [‘dict’, ‘string’],
‘check_with’: ‘bulk_schema’}]}
-
_validate_allowed(allowed_values, field, value)¶ {‘type’: ‘container’}
-
_validate_anyof(definitions, field, value)¶ {‘type’: ‘list’, ‘logical’: ‘anyof’}
-
_validate_check_with(checks, field, value)¶ {‘oneof’: [ {‘type’: ‘callable’}, {‘type’: ‘list’,
- ‘schema’: {‘oneof’: [{‘type’: ‘callable’},
- {‘type’: ‘string’}]}},
{‘type’: ‘string’} ]}
-
_validate_contains(expected_values, field, value)¶ {‘empty’: False }
-
_validate_dependencies(dependencies, field, value)¶ {‘type’: (‘dict’, ‘hashable’, ‘list’), ‘check_with’: ‘dependencies’}
-
_validate_empty(empty, field, value)¶ {‘type’: ‘boolean’}
-
_validate_excludes(excluded_fields, field, value)¶ {‘type’: (‘hashable’, ‘list’), ‘schema’: {‘type’: ‘hashable’}}
-
_validate_forbidden(forbidden_values, field, value)¶ {‘type’: ‘list’}
-
_validate_items(items, field, values)¶ {‘type’: ‘list’, ‘check_with’: ‘items’}
-
_validate_keysrules(schema, field, value)¶ {‘type’: [‘dict’, ‘string’], ‘check_with’: ‘bulk_schema’, ‘forbidden’: [‘rename’, ‘rename_handler’]}
-
_validate_max(max_value, field, value)¶ {‘nullable’: False }
-
_validate_maxlength(max_length, field, value)¶ {‘type’: ‘integer’}
-
_validate_min(min_value, field, value)¶ {‘nullable’: False }
-
_validate_minlength(min_length, field, value)¶ {‘type’: ‘integer’}
-
_validate_noneof(definitions, field, value)¶ {‘type’: ‘list’, ‘logical’: ‘noneof’}
-
_validate_nullable(nullable, field, value)¶ {‘type’: ‘boolean’}
-
_validate_oneof(definitions, field, value)¶ {‘type’: ‘list’, ‘logical’: ‘oneof’}
-
_validate_readonly(readonly, field, value)¶ {‘type’: ‘boolean’}
-
_validate_regex(pattern, field, value)¶ {‘type’: ‘string’}
-
_validate_require_all(constraint, field, value)¶ {‘type’: ‘boolean’}
-
_validate_required(constraint, field, value)¶ {‘type’: ‘boolean’}
-
_validate_schema(schema, field, value)¶ {‘type’: [‘dict’, ‘string’], ‘anyof’: [{‘check_with’: ‘schema’},
{‘check_with’: ‘bulk_schema’}]}
-
_validate_type(data_type, field, value)¶ {‘type’: [‘string’, ‘list’], ‘check_with’: ‘type’}
-
_validate_valuesrules(schema, field, value)¶ {‘type’: [‘dict’, ‘string’], ‘check_with’: ‘bulk_schema’, ‘forbidden’: [‘rename’, ‘rename_handler’]}
-
allow_unknown¶ If
Trueunknown fields that are not defined in the schema will be ignored. If a mapping with a validation schema is given, any undefined field will be validated against its rules. Also see allowing-the-unknown. Type:boolor any mapping
-
classmethod
clear_caches()¶ Purge the cache of known valid schemas.
-
errors¶ The errors of the last processing formatted by the handler that is bound to
error_handler.
-
ignore_none_values¶ Whether to not process
None-values in a document or not. Type:bool
-
is_child¶ Truefor child-validators obtained with_get_child_validator(). Type:bool
-
normalized(document, schema=None, always_return_document=False)¶ Returns the document normalized according to the specified rules of a schema.
Parameters: - document (any mapping) – The document to normalize.
- schema (any mapping) – The validation schema. Defaults to
None. If not provided here, the schema must have been provided at class instantiation. - always_return_document (
bool) – Return the document, even if an error occurred. Defaults to:False.
Returns: A normalized copy of the provided mapping or
Noneif an error occurred during normalization.
-
purge_readonly¶ If
True, fields declared as readonly will be deleted from the document unless a validation is called with disabled normalization. Type:bool
-
purge_unknown¶ If
True, unknown fields will be deleted from the document unless a validation is called with disabled normalization. Also see purging-unknown-fields. Type:bool
-
require_all¶ If
Trueknown fields that are defined in the schema will be required. Type:bool
-
root_allow_unknown¶ The
allow_unknownattribute of the first level ancestor of a child validator.
-
root_document¶ The
documentattribute of the first level ancestor of a child validator.
-
root_require_all¶ The
require_allattribute of the first level ancestor of a child validator.
-
root_schema¶ The
schemaattribute of the first level ancestor of a child validator.
-
rules_set_registry¶ The registry that holds referenced rules sets. Type:
Registry
-
schema¶ The validation schema of a validator. When a schema is passed to a method, it replaces this attribute. Type: any mapping or
None
-
schema_registry¶ The registry that holds referenced schemas. Type:
Registry
-
validate(document, schema=None, update=False, normalize=True)¶ Normalizes and validates a mapping against a validation-schema of defined rules.
Parameters: - document (any mapping) – The document to normalize.
- schema (any mapping) – The validation schema. Defaults to
None. If not provided here, the schema must have been provided at class instantiation. - update (
bool) – IfTrue, required fields won’t be checked. - normalize (
bool) – IfTrue, normalize the document before validation.
Returns: Trueif validation succeeds, otherwiseFalse. Check theerrors()property for a list of processing errors.Return type: bool
-
validate_presence_if_value(document, field, value, required_field)¶ Method checks presence of key based on another field and its value.
Parameters: - document (dict) – Dictionary to check
- field – Dependent field for required field
- value – Value of a dependent field
- () (required_field) – Field which should be present
Returns: True - valid (required field is in document), False - invalid (required field is not in document)
Return type: bool
-
validated(*args, **kwargs)¶ Wrapper around
validate()that returns the normalized and validated document orNoneif validation failed.
-
-
selenium_generator.validators.validator.SchemaValidator(config_schema='/home/docs/checkouts/readthedocs.org/user_builds/selenium-generator/checkouts/release-0.2/selenium_generator/validators/schemas/config_schema.json', scenario_schema='/home/docs/checkouts/readthedocs.org/user_builds/selenium-generator/checkouts/release-0.2/selenium_generator/validators/schemas/scenario_schema.json', driver_schema='/home/docs/checkouts/readthedocs.org/user_builds/selenium-generator/checkouts/release-0.2/selenium_generator/validators/schemas/driver_schema.json')¶ Parameters: - config_schema –
- scenario_schema –
- driver_schema –
-
selenium_generator.validators.validator.v¶ Type: ExtendedValidator
-
selenium_generator.validators.validator.config_schema¶
-
selenium_generator.validators.validator.scenario_schema¶
-
selenium_generator.validators.validator.driver_schema¶