summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-02-15 22:31:51 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-02-15 22:50:26 +0100
commitd8ecc510108426fba8f9a53e0d5fa54d5942e75f (patch)
treed37c1fe311be473745df1717bc213afb976133eb /tests
parent72ff759384538d412b5114d72b3115b730c06406 (diff)
downloadpython-linuxnamespaces-d8ecc510108426fba8f9a53e0d5fa54d5942e75f.tar.gz
MountFlags: support conversion to and from a textual representation
The textual representation matches util-linux. Not all flag values can be represented textually.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_simple.py18
1 files changed, 18 insertions, 0 deletions
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()