diff --git a/boltons/fileutils.py b/boltons/fileutils.py index 5ddaabd..0e9bdc0 100644 --- a/boltons/fileutils.py +++ b/boltons/fileutils.py @@ -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() diff --git a/tests/test_fileutils.py b/tests/test_fileutils.py new file mode 100644 index 0000000..74259dd --- /dev/null +++ b/tests/test_fileutils.py @@ -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