Ready to Use Utilities
pytest-mh codebase contains several generic, ready to use utilities that
can be added to hosts and roles. These utilities add support for various
project independent tasks, such as reading and writing files, managing firewall,
automatic collection of core dumps and much more.
In order to use these utilities, simply import them in your python module and add them to your role or host.
Warning
Only utilities that inherits from
MultihostReentrantUtility can be safely used in both
MultihostRole and MultihostHost
object. Other classes should be used only in
MultihostRole.
from pytest_mh import MultihostHost
from pytest_mh.utils.fs import LinuxFileSystem
from pytest_mh.utils.services import SystemdServices
class ExampleRole(MultihostHost[ExampleDomain]):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.fs: LinuxFileSystem = LinuxFileSystem(self)
"""
File system utilities.
"""
self.svc: SystemdServices = SystemdServices(self)
"""
Systemd utilities.
"""
These utilities are automatically initialized, setup and teardown. You can start using them right away. Any changes made to the host by these utilities during a test run will be automatically reverted.
Note
We welcome contributions that add more project independent utilities.