From d8ecc510108426fba8f9a53e0d5fa54d5942e75f Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 15 Feb 2024 22:31:51 +0100 Subject: MountFlags: support conversion to and from a textual representation The textual representation matches util-linux. Not all flag values can be represented textually. --- tests/test_simple.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test_simple.py') diff --git a/tests/test_simple.py b/tests/test_simple.py index cb654aa..960bf02 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -12,6 +12,24 @@ import pytest import linuxnamespaces +class MountFlagsTest(unittest.TestCase): + def test_tostrfromstr(self) -> None: + for bit1 in range(32): + for bit2 in range(bit1, 32): + flag = ( + linuxnamespaces.MountFlags(1 << bit1) + | linuxnamespaces.MountFlags(1 << bit2) + ) + try: + text = flag.tostr() + except ValueError: + continue + self.assertEqual( + linuxnamespaces.MountFlags.fromstr(text), + flag + ) + + class IDAllocationTest(unittest.TestCase): def test_idalloc(self) -> None: alloc = linuxnamespaces.IDAllocation() -- cgit v1.2.3