monkeypatch.setattr(decorators.os, 'getuid', lambda: 0)
assert decorators.needs_root(func)() is True
+ def test_is_not_root_env_var_skip_needs_root(self, monkeypatch):
+ def func():
+ return True
+ monkeypatch.setattr(decorators.os, 'getuid', lambda: 123)
+ monkeypatch.setattr(decorators.os, 'environ', {'CEPH_VOLUME_SKIP_NEEDS_ROOT': '1'})
+ assert decorators.needs_root(func)() is True
+
def test_is_not_root(self, monkeypatch):
def func():
return True # pragma: no cover