import unittest
from test import support
+import os
+import stat
import sys
import uu
import io
with open(self.tmpin, 'rb') as f:
self.assertRaises(uu.Error, uu.decode, f)
+ def test_decode_mode(self):
+ # Verify that decode() will set the given mode for the out_file
+ expected_mode = 0o444
+ with open(self.tmpin, 'wb') as f:
+ f.write(encodedtextwrapped(expected_mode, self.tmpout))
+
+ # make file writable again, so it can be removed (Windows only)
+ self.addCleanup(os.chmod, self.tmpout, expected_mode | stat.S_IWRITE)
+
+ with open(self.tmpin, 'rb') as f:
+ uu.decode(f)
+
+ self.assertEqual(
+ stat.S_IMODE(os.stat(self.tmpout).st_mode),
+ expected_mode
+ )
+
if __name__=="__main__":
unittest.main()
out_file = sys.stdout.buffer
elif isinstance(out_file, str):
fp = open(out_file, 'wb')
- try:
- os.path.chmod(out_file, mode)
- except AttributeError:
- pass
+ os.chmod(out_file, mode)
out_file = fp
opened_files.append(out_file)
#