From 48cc85e88c5ec76deaaf50535c0f8dfd72e8bdc7 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 3 Jun 2016 16:04:12 -0700 Subject: [PATCH] add file-mode checks to directory test This new test failed before fixing _extract_file, and now it passes. --- src/wormhole/test/test_scripts.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wormhole/test/test_scripts.py b/src/wormhole/test/test_scripts.py index 6ccd5f1..63e3a5c 100644 --- a/src/wormhole/test/test_scripts.py +++ b/src/wormhole/test/test_scripts.py @@ -1,5 +1,5 @@ from __future__ import print_function -import os, sys, re, io, zipfile, six +import os, sys, re, io, zipfile, six, stat import mock from twisted.trial import unittest from twisted.python import procutils, log @@ -288,9 +288,14 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase): os.mkdir(os.path.join(send_dir, "middle")) source_dir = os.path.join(send_dir, "middle", send_dirname) os.mkdir(source_dir) + modes = {} for i in range(5): - with open(os.path.join(source_dir, str(i)), "w") as f: + path = os.path.join(source_dir, str(i)) + with open(path, "w") as f: f.write(message(i)) + if i == 3: + os.chmod(path, 0o755) + modes[i] = stat.S_IMODE(os.stat(path).st_mode) send_dirname_arg = os.path.join("middle", send_dirname) if addslash: send_dirname_arg += os.sep @@ -413,6 +418,8 @@ class PregeneratedCode(ServerBase, ScriptsBase, unittest.TestCase): fn = os.path.join(receive_dir, receive_dirname, str(i)) with open(fn, "r") as f: self.failUnlessEqual(f.read(), message(i)) + self.failUnlessEqual(modes[i], + stat.S_IMODE(os.stat(fn).st_mode)) def test_text(self): return self._do_test()