use with statement
This commit is contained in:
parent
c2dafe60bc
commit
3c0027b721
|
@ -324,10 +324,9 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
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')
|
||||
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:
|
||||
|
@ -335,7 +334,6 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
response = self.request(self.tempdir_name + '/')
|
||||
self.check_status_and_reason(response, 404)
|
||||
os.chmod(self.tempdir, 0755)
|
||||
f.close()
|
||||
|
||||
def test_head(self):
|
||||
response = self.request(
|
||||
|
|
Loading…
Reference in New Issue