diff options
author | Timo Furrer <tuxtimo@gmail.com> | 2019-01-17 14:15:53 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-01-17 14:15:53 (GMT) |
commit | 17f05bbc78dbcd1db308266c31370da9ec1b1d47 (patch) | |
tree | 27fd4f29df7b62bdad0400bd151fcf1d1d3d9689 /Lib/test/test_uu.py | |
parent | f1d8e7cf17a010d2657822e06a41b30c9542a8c7 (diff) | |
download | cpython-17f05bbc78dbcd1db308266c31370da9ec1b1d47.zip cpython-17f05bbc78dbcd1db308266c31370da9ec1b1d47.tar.gz cpython-17f05bbc78dbcd1db308266c31370da9ec1b1d47.tar.bz2 |
bpo-33687: Fix call to os.chmod() in uu.decode() (GH-7282)
Diffstat (limited to 'Lib/test/test_uu.py')
-rw-r--r-- | Lib/test/test_uu.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index 1147205..c9f05e5 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -6,6 +6,8 @@ Nick Mathewson import unittest from test import support +import os +import stat import sys import uu import io @@ -218,6 +220,23 @@ class UUFileTest(unittest.TestCase): 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() |