From b528af673dcf3dd1b06a467b3b147a75d52d6181 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Thu, 24 Nov 2022 15:03:28 +0800 Subject: Add tests for unmount flags --- tests/test_libmount.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests/test_libmount.py') diff --git a/tests/test_libmount.py b/tests/test_libmount.py index b9a5c15..8e56970 100644 --- a/tests/test_libmount.py +++ b/tests/test_libmount.py @@ -22,7 +22,8 @@ class LibMountTests(TestCase): libmount.mount(source="", target=path, fs="tmpfs") yield path finally: - libmount.unmount(target=path) + with suppress(OSError): + libmount.unmount(path) def test_mount(self): """Test normal mounting.""" @@ -62,6 +63,23 @@ class LibMountTests(TestCase): finally: libmount.unmount(target=path) + def test_unmount_flags(self): + """Test unmount flags.""" + flags = [ + libmount.UnmountFlags.MNT_FORCE, + libmount.UnmountFlags.MNT_DETACH, + libmount.UnmountFlags.UMOUNT_NOFOLLOW, + ] + for flag in flags: + with self.subTest(flag=flag), self.get_mount() as path: + libmount.unmount(path, flag) + + def test_unmount_flags_expire(self): + """Test unmount MNT_EXPIRE behavior.""" + with self.get_mount() as path: + with self.assertRaises(BlockingIOError): + libmount.unmount(path, libmount.UnmountFlags.MNT_EXPIRE) + def test_unmount_errors(self): """Test invalid unmount errors.""" cases = [ -- cgit v1.2.3