mirror of https://github.com/mahmoud/boltons.git
adding FilePerms tests
This commit is contained in:
parent
7c0b237741
commit
d3a6c9743f
|
@ -408,22 +408,8 @@ copytree = copy_tree # alias for drop-in replacement of shutil
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
#with atomic_save('/tmp/final.txt') as f:
|
||||
# f.write('rofl')
|
||||
# raise ValueError('nope')
|
||||
# f.write('\n')
|
||||
|
||||
def _main():
|
||||
up = FilePerms()
|
||||
up.other = ''
|
||||
up.user = 'xrw'
|
||||
up.group = 'rrrwx'
|
||||
try:
|
||||
up.other = 'nope'
|
||||
except ValueError:
|
||||
pass
|
||||
print(up)
|
||||
print('user:', up.user)
|
||||
print(oct(int(up)))
|
||||
print(oct(int(FilePerms())))
|
||||
_main()
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from boltons.fileutils import FilePerms
|
||||
|
||||
|
||||
def test_fileperms():
|
||||
up = FilePerms()
|
||||
up.other = ''
|
||||
up.user = 'xrw'
|
||||
up.group = 'rrrwx'
|
||||
try:
|
||||
up.other = 'nope'
|
||||
except ValueError:
|
||||
# correctly raised ValueError on invalid chars
|
||||
pass
|
||||
|
||||
assert repr(up) == "FilePerms(user='rwx', group='rwx', other='')"
|
||||
assert up.user == 'rwx'
|
||||
assert oct(int(up)).endswith('770') # 0770 on py2 and 0o770 on py3
|
||||
|
||||
assert int(FilePerms()) == 0
|
Loading…
Reference in New Issue