1313
1414import pytest
1515
16+
17+ def _can_unshare_userns () -> bool :
18+ """Check if the system supports unprivileged user namespaces."""
19+ try :
20+ result = subprocess .run (
21+ ["unshare" , "--user" , "--map-root-user" , "true" ],
22+ capture_output = True , timeout = 5 ,
23+ )
24+ return result .returncode == 0
25+ except (FileNotFoundError , subprocess .TimeoutExpired ):
26+ return False
27+
28+
1629needs_branchfs = pytest .mark .skipif (
1730 not os .environ .get ("BRANCHFS_MOUNT" ),
1831 reason = "BRANCHFS_MOUNT not set (no live branchfs)" ,
1932)
2033
34+ needs_userns = pytest .mark .skipif (
35+ not _can_unshare_userns (),
36+ reason = "Kernel does not support unprivileged user namespaces" ,
37+ )
38+
2139
2240@pytest .fixture
2341def ws ():
@@ -100,6 +118,7 @@ def test_sibling_branches_first_wins(ws):
100118
101119
102120@needs_branchfs
121+ @needs_userns
103122def test_speculate_parallel (ws ):
104123 """Speculate runs candidates in parallel, commits the winner."""
105124 from branching import Speculate
@@ -121,6 +140,7 @@ def candidate_fail(path: Path) -> bool:
121140
122141
123142@needs_branchfs
143+ @needs_userns
124144def test_tree_of_thoughts_multi_level (ws ):
125145 """TreeOfThoughts with expand commits accumulated state across levels."""
126146 from branching import TreeOfThoughts
0 commit comments