dice.core package

Submodules

dice.core.constraint module

class dice.core.constraint.Constraint(name, provider, depends_on=None, require=None, oracle=None)[source]

Bases: object

Class for a constraint on specific option of test item.

apply(item)[source]

Apply this constraint to an item.

Parameters:item – The item to be applied on.
Returns:Expected result of constraint item.
classmethod from_dict(provider, data)[source]

Generate a constraint instance from a dictionary

path_prefix = 'DPATH'
exception dice.core.constraint.ConstraintError[source]

Bases: exceptions.Exception

Constraint module specified exception.

class dice.core.constraint.ConstraintManager(provider)[source]

Bases: object

Manager class contains and manipulates all constraints.

constrain(item)[source]

Apply constraints to an item.

Parameters:item – Item for constraints to apply on.

dice.core.item module

class dice.core.item.ItemBase(provider)[source]

Bases: object

Base class for an item. This should be overridden in the providers item.py.

get(path)[source]

Get value for specific item option.

Parameters:path – An XPath-like string for the getting target.
Returns:Option value got.
run()[source]

Run the item. Must be overridden in the providers.

set(path, value)[source]

Set value for specific item option.

Parameters:
  • path – An XPath-like string for the setting target.
  • value – Option value to be set.
exception dice.core.item.ItemError[source]

Bases: exceptions.Exception

Class for Item specific exceptions.

dice.core.provider module

class dice.core.provider.Provider(path)[source]

Bases: object

Class for a dice test provider.

generate()[source]

Generate a new constrained test item.

Returns:Constrained item.
exception dice.core.provider.ProviderError[source]

Bases: exceptions.Exception

Class for provider specific exceptions.

dice.core.symbol module

class dice.core.symbol.Bytes(scope=None, excs=None, exc_types=None)[source]

Bases: dice.core.symbol.SymbolBase

Symbol class for a string contains random bytes (1~255).

generate()[source]

Generate a random bytes string.

class dice.core.symbol.Integer(scope=None, excs=None, exc_types=None)[source]

Bases: dice.core.symbol.SymbolBase

Symbol class for a random integer.

generate()[source]

Generate a random integer.

class dice.core.symbol.NonEmptyBytes(scope=None, excs=None, exc_types=None)[source]

Bases: dice.core.symbol.Bytes

Symbol class for a random byte(1-255) string except empty string.

generate()[source]

Generate a random non-empty bytes string.

class dice.core.symbol.String(scope=None, excs=None, exc_types=None)[source]

Bases: dice.core.symbol.Bytes

Symbol class for a random printable string.

generate()[source]

Generate a random printable string.

class dice.core.symbol.StringList(scope=None, excs=None, exc_types=None)[source]

Bases: dice.core.symbol.SymbolBase

Symbol class for a list of random printable strings.

generate()[source]

Generate a random printable strings.

model()[source]

Generate a random-numbered list contains random printable strings.

class dice.core.symbol.SymbolBase(scope=None, excs=None, exc_types=None)[source]

Bases: object

Base class for a symbol object represent a catalog of data to be randomized.

generate()[source]

Generate a random instance of this symbol without considering scope, excs or exc_types. Must be overridden.

model()[source]

Generate a random instance of this symbol.

dice.core.trace module

class dice.core.trace.Trace(provider, trace_list)[source]

Bases: object

Class represent a condition trace in constraint oracle code. It contains a list of commands, including comparisons, operations and ends with a return command.

solve(item)[source]

Generate a satisfiable random option according to this trace. :param item: Item to which generated option applies. :return: Generated random option.

exception dice.core.trace.TraceError[source]

Bases: exceptions.Exception

Class for trace specific exceptions.

Module contents