Skip to content

Commit dee08f2

Browse files
disserphilpep
authored andcommitted
Add docstrings to User and Group .exists properties.
1 parent 6bf3f87 commit dee08f2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

testinfra/modules/group.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ def __init__(self, name=None):
2222

2323
@property
2424
def exists(self):
25+
"""Test if group exists
26+
27+
>>> host.group("wheel").exists
28+
True
29+
>>> host.group("nosuchgroup").exists
30+
False
31+
32+
"""
33+
2534
return self.run_expect([0, 2], "getent group %s", self.name).rc == 0
2635

2736
@property

testinfra/modules/user.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def name(self):
3434

3535
@property
3636
def exists(self):
37+
"""Test if user exists
38+
39+
>>> host.user("root").exists
40+
True
41+
>>> host.user("nosuchuser").exists
42+
False
43+
44+
"""
45+
3746
return self.run_test("id %s", self.name).rc == 0
3847

3948
@property
@@ -145,6 +154,15 @@ def name(self):
145154

146155
@property
147156
def exists(self):
157+
"""Test if user exists
158+
159+
>>> host.user("Administrator").exists
160+
True
161+
>>> host.user("nosuchuser").exists
162+
False
163+
164+
"""
165+
148166
return self.run_test("net user %s", self.name).rc == 0
149167

150168
@property

0 commit comments

Comments
 (0)