greentea package

A microframework for abstraction.

Submodules

greentea.first_class_collection module

Provide classes that represent first class collections.

class greentea.first_class_collection.FirstClassFileContextManagerProvider(filename: str)[source]

Bases: object

Provide a context manager.

abstract transform(item)[source]
class greentea.first_class_collection.FirstClassSequence[source]

Bases: object

apply_function(function: Callable[[T], S]) → Generator[S, None, None][source]
filter_by_container(container: Container[T]) → Generator[T, None, None][source]

Return generator that emits items that container contains.

is_empty() → bool[source]

Return True if sequence() is empty.

abstract property sequence

Return the items.

greentea.log module

Configure the logging system for snippets.

class greentea.log.LogConfiguration(verbose: bool, name: str)[source]

Bases: object

Logging configuration.

verbose
Type

bool

name
Type

str

configure() → None[source]

Update the logging level of name logger.

greentea.primitive module

Implement a wrapper for primitive and strings.

class greentea.primitive.Primitive[source]

Bases: object

Wrapper for primitive and strings.

handle(handler: Callable[[T], S]) → S[source]

Apply a function to primitive().

abstract property primitive

Return the raw value.

greentea.trace module

Provide methods to trace execution.

class greentea.trace.Invocation(invocation: Tuple[Callable, Tuple, dict], start_time: datetime.datetime)[source]

Bases: object

Record an invocation of a function.

build_end_message(return_value: Any) → str[source]

Create a message that this invocation has ended.

build_start_message() → str[source]

Create a message that represents this invocation.

classmethod create_from(function: Callable, args: Tuple, kwargs: dict)[source]

Record the time when a function is called.

Returns

trace

Return type

Trace

class greentea.trace.TraceLevel(start_level: int = 10, end_level: int = 10)[source]

Bases: object

Represent logging levels for tracing executions.

end(logger: logging.Logger, invocation: greentea.trace.Invocation, return_value: Any) → None[source]

Record that the function has end.

end_level = 10
start(logger: logging.Logger, invocation: greentea.trace.Invocation) → None[source]

Record trace with logger.

start_level = 10
class greentea.trace.Tracer(logger: logging.Logger, trace_level: greentea.trace.TraceLevel)[source]

Bases: object

Record information about a program’s execution.

classmethod create_tracer(logger_name: str = 'trace', format_string: str = '%(levelname)s:%(asctime)s:%(name)s:%(message)s', level: int = 10, trace_level: greentea.trace.TraceLevel = TraceLevel(start_level=10, end_level=10))[source]

Create a tracer named with logger_name.

Returns

tracer

Return type

Tracer

trace(function: Callable)[source]

Provide a function decorator to trace the decorated function.

greentea.typevar module

Provide typevars.