diff --git a/test/test_modules.py b/test/test_modules.py index 15416344..c4bc91a0 100644 --- a/test/test_modules.py +++ b/test/test_modules.py @@ -482,12 +482,14 @@ def test_supervisor(host, supervisorctl_path, supervisorctl_conf): def test_mountpoint(host): root_mount = host.mount_point("/") assert root_mount.exists + assert repr(root_mount) assert isinstance(root_mount.options, list) assert "rw" in root_mount.options assert root_mount.filesystem fake_mount = host.mount_point("/fake/mount") assert not fake_mount.exists + assert repr(fake_mount) mountpoints = host.mount_point.get_mountpoints() assert mountpoints diff --git a/testinfra/modules/mountpoint.py b/testinfra/modules/mountpoint.py index 4fd5369e..3757ca6f 100644 --- a/testinfra/modules/mountpoint.py +++ b/testinfra/modules/mountpoint.py @@ -101,13 +101,17 @@ def get_module_class(cls, host): raise NotImplementedError def __repr__(self): + if self.exists: + d = self.device + f = self.filesystem + o = ",".join(self.options) + else: + d = "" + f = "" + o = "" return ( - "" - ).format( - self.path, - self.device, - self.filesystem, - ",".join(self.options), + f'' )