Test module#
- class ansys.scadeone.core.swan.harness.TestModule(name: PathIdentifier, use_directives: List[UseDirective] | None = None, declarations: List[GlobalDeclaration] | None = None, pragmas: List[Pragma] | None = None)#
Bases:
Module,TestModuleCreatorTest module definition.
- body() ModuleBody | None#
Return the module body for a module interface if it exists.
- filter_declarations(filter_fn: Callable[[ModuleItem], bool]) List[ModuleItem]#
Return declarations matched by a filter.
- Parameters:
- filter_fn
Callable[[common.ModuleItem], bool] A function of one argument of type ModuleItem, returning True or False.
- filter_fn
- Returns:
List[ModuleItem]List of matching declarations.
- get_declaration(name: str) Declaration | None#
Return the type, sensor, group, constant, or operator declaration searching by namespace.
- get_use_directive(module_name: str) UseDirective | None#
Return the use directive searching by module name or alias name.
Aliases are searched first, the module name is searched if no alias is found. When a module name is searched, use directive with first occurrence is returned.
- interface() ModuleInterface | None#
Return the module interface for a module body if it exists.
- static module_name_from_path(path: Path) str#
Returns a module name from a path.
- Parameters:
- path
Path Path to the module, e.g. /path/to/namespace-module.swan
- path
- Returns:
strModule name, e.g. namespace::module
- static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) None#
Helper to set owner as the owner of each item in the Iterable items.
- Parameters:
- owner
SwanItem Owner of the items.
- children
Union[SwanItem,Iterable[SwanItem],None] Items to set owner.
- owner
- use(module: swan.Module | str, alias: str = None) swan.UseDirective#
Add a use directive to the module.
- Parameters:
- module: Module
Module name.
- alias: str
Module alias.
- Returns:
UseDirectiveUseDirective object.
- property declarations: List[ModuleItem]#
Module’s declarations
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property name: PathIdentifier#
Module or Interface name.
- property operator_declarations: List[OperatorDeclaration]#
Return a list of operator declarations.
- property operator_definitions: List[OperatorDefinition]#
Return a list of operator definitions.
- property sensors: List[SensorDecl]#
Return a list of sensor declarations.
- property test_harnesses: List[TestHarness]#
Return a list of test harness.
- property use_directives: List[UseDirective]#
Module’s use directives as a list.