Skip to content

Commit ee566da

Browse files
romainxphilpep
andauthored
Fix #594: mode documentation (#595)
Co-authored-by: Philippe Pepiot <[email protected]>
1 parent 593d4f6 commit ee566da

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

testinfra/modules/file.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,23 @@ def gid(self):
9393
def mode(self):
9494
"""Return file mode as octal integer
9595
96-
>>> host.file("/etc/passwd").mode
97-
384 # 0o600 (octal)
98-
>>> host.file("/etc/password").mode == 0o600
96+
>>> host.file("/etc/shadow").mode
97+
416 # Oo640 octal
98+
>>> host.file("/etc/shadow").mode == 0o640
9999
True
100-
>>> oct(host.file("/etc/password").mode) == '0600'
100+
>>> oct(host.file("/etc/shadow").mode) == '0o640'
101101
True
102102
103-
Note: Python 3 oct(x)_ function will produce ``'0o600'``
104-
105103
You can also utilize the file mode constants from
106104
the stat_ library for testing file mode.
107105
108106
>>> import stat
109-
>>> host.file("/etc/password").mode == stat.S_IRUSR | stat.S_IWUSR
107+
>>> host.file("/etc/shadow").mode == stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP
110108
True
111109
112-
.. _oct(x): https://docs.python.org/3.5/library/functions.html#oct
113-
.. _stat: https://docs.python.org/2/library/stat.html
114-
"""
110+
.. _oct(x): https://docs.python.org/3/library/functions.html#oct
111+
.. _stat: https://docs.python.org/3/library/stat.html
112+
""" # noqa
115113
raise NotImplementedError
116114

117115
def contains(self, pattern):

0 commit comments

Comments
 (0)