Skip to content

aea.test_tools.utils

Helpful utilities.

wait_for_condition

def wait_for_condition(condition_checker: Callable,
                       timeout: int = 2,
                       error_msg: str = "Timeout",
                       period: float = 0.001) -> None

Wait for condition to occur in selected timeout.

consume

def consume(iterator: Iterable) -> None

Consume the iterator

as_context

@contextmanager
def as_context(*contexts: Any) -> Generator[None, None, None]

Set contexts

copy_class

def copy_class(cls: Type) -> Type

Copy a class. Useful for testing class setup configurations

remove_test_directory

def remove_test_directory(directory: Union[str, Path],
                          retries: int = 3) -> bool

Destroy a directory once tests are done, change permissions if needed.

Note that on Windows directories and files that are open cannot be deleted.

Arguments:

  • directory: directory to be deleted
  • retries: number of re-attempts

Returns:

whether the directory was successfully deleted