report package

report (Report Module)

Author:

Description:

The Module is designed to help with python logging and to support some handlers for logging to memory.

Submodules:

Unittest:

See also the unittest documentation.

report.DEFAULT_FMT = '%(asctime)s: %(levelname)8s - %(name)s - %(message)s\n                                    File "%(pathname)s", line %(lineno)d, in %(funcName)s'

The default formatstring

report.JOURNAL_FMT = '%(levelname)8s - %(name)s - %(message)s'

A short journal formatter including the most important information

class report.JsonFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)

Bases: Formatter

format(record)

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

report.LONG_FMT = '%(asctime)s: %(levelname)8s - %(name)s - %(message)s\n                                    File "%(pathname)s", line %(lineno)d, in %(funcName)s'

A long formatter which results in links to the source code inside Eclipse

report.SHORT_FMT = '%(asctime)s: %(levelname)8s - %(name)s - %(message)s'

A short formatter including the most important information

report.TCEL_FULL = 90

Testcase level (full), this is a complete test for the full functionality

report.TCEL_NAMES = {0: 'Single Test', 10: 'Smoke Test (Minumum subset)', 50: 'Short Test (Subset)', 90: 'Full Test (all defined tests)'}

Dictionary for resolving the test case levels (TCL) to a (human readable) name

report.TCEL_REVERSE_NAMED = {'full': 90, 'short': 50, 'single': 0, 'smoke': 10}

Dictionary for resolving named test case levels (TCL) to test case level number

report.TCEL_SHORT = 50

Testcase level (short), this is a short test for an extended functionality

report.TCEL_SINGLE = 0

Testcase level (smoke), this is just a rough test for the main functionality

report.TCEL_SMOKE = 10

Testcase level (smoke), this is just a rough test for the main functionality

report.add_handler_file(logger: Logger, filename: str, maxMbytes: int, backupCount: int, level: int = 10, fmt: str = '%(asctime)s: %(levelname)8s - %(name)s - %(message)s\n                                    File "%(pathname)s", line %(lineno)d, in %(funcName)s') RotatingFileHandler
report.add_handler_socket(logger: Logger, level: int = 10, host: str = 'localhost', port: int = 19996) SocketHandler
report.add_handler_stdout(logger: Logger, level: int = 30, fmt: str = '%(asctime)s: %(levelname)8s - %(name)s - %(message)s\n                                    File "%(pathname)s", line %(lineno)d, in %(funcName)s') StreamHandler
report.app_logging_config()

For details see comment in default_logging_config.

class report.collectingHandler

Bases: Handler

MY_LOGS = []
emit(record)

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

get_logs()
get_str(logs=None, fmt='%(asctime)s: %(levelname)8s - %(name)s - %(message)s')
make_independent()
class report.collectingRingHandler(max_logs=None)

Bases: collectingHandler

MY_LOGS = deque([], maxlen=10)
get_logs()
make_independent()
class report.collectingTestcaseHandler

Bases: collectingHandler

MY_LOGS = []
emit(record)

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

report.default_logging_config(fmt='%(levelname)8s - %(name)s - %(message)s')

You are able to configure logging by a config file including these line:

import logging

DEBUG = False # # Logging # APP_NAME = “<YOUR_APP_NAME>” LOG_HOSTNAME = “loggy” # When DEBUG is True LOG_LEVEL = logging.INFO # STDOUT logging

class report.testSession(module_names=[], **kwargs)

Bases: dict

DEFAULT_BASE_DATA = {'name': 'Default Testsession name', 'number_of_failed_tests': 0, 'number_of_possibly_failed_tests': 0, 'number_of_successfull_tests': 0, 'number_of_tests': 0, 'testcase_execution_level': 90, 'testcase_names': {0: 'Single Test', 10: 'Smoke Test (Minumum subset)', 50: 'Short Test (Subset)', 90: 'Full Test (all defined tests)'}}
KEY_ALL_TESTS = 'number_of_tests'
KEY_EXEC_LVL = 'testcase_execution_level'
KEY_EXEC_NAMES = 'testcase_names'
KEY_FAILED_TESTS = 'number_of_failed_tests'
KEY_LVL_NAMES = 'level_names'
KEY_NAME = 'name'
KEY_POSSIBLY_FAILED_TESTS = 'number_of_possibly_failed_tests'
KEY_SUCCESS_TESTS = 'number_of_successfull_tests'
KEY_TESTCASELIST = 'testcases'
KEY_UID_LIST = 'uid_list_sorted'
testCase(name, testcase_execution_level, test_method, *args, **kwargs)