[Python-checkins] cpython (2.7): use with statement
benjamin.peterson
python-checkins at python.org
Fri Apr 4 20:00:12 CEST 2014
http://hg.python.org/cpython/rev/87c150c43ca8
changeset: 90146:87c150c43ca8
branch: 2.7
parent: 90144:d7a37a1f2ca9
user: Benjamin Peterson <benjamin at python.org>
date: Fri Apr 04 13:59:33 2014 -0400
summary:
use with statement
files:
Lib/test/test_httpservers.py | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -324,18 +324,16 @@
self.check_status_and_reason(response, 404)
response = self.request('/' + 'ThisDoesNotExist' + '/')
self.check_status_and_reason(response, 404)
- f = open(os.path.join(self.tempdir_name, 'index.html'), 'w')
- response = self.request('/' + self.tempdir_name + '/')
- self.check_status_and_reason(response, 200)
-
- # chmod() doesn't work as expected on Windows, and filesystem
- # permissions are ignored by root on Unix.
- if os.name == 'posix' and os.geteuid() != 0:
- os.chmod(self.tempdir, 0)
- response = self.request(self.tempdir_name + '/')
- self.check_status_and_reason(response, 404)
- os.chmod(self.tempdir, 0755)
- f.close()
+ with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as fp:
+ response = self.request('/' + self.tempdir_name + '/')
+ self.check_status_and_reason(response, 200)
+ # chmod() doesn't work as expected on Windows, and filesystem
+ # permissions are ignored by root on Unix.
+ if os.name == 'posix' and os.geteuid() != 0:
+ os.chmod(self.tempdir, 0)
+ response = self.request(self.tempdir_name + '/')
+ self.check_status_and_reason(response, 404)
+ os.chmod(self.tempdir, 0755)
def test_head(self):
response = self.request(
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list