packaging: use with open() instead of try/finally: close

This commit is contained in:
Victor Stinner 2011-05-19 15:51:27 +02:00
parent 0e3f3a7076
commit 21a9c748aa
11 changed files with 41 additions and 69 deletions

View file

@ -54,11 +54,9 @@ class PyPIServerTest(unittest.TestCase):
url = server.full_address + url_path
request = urllib.request.Request(url)
response = urllib.request.urlopen(request)
file = open(PYPI_DEFAULT_STATIC_PATH + "/test_pypi_server" +
url_path)
answer = response.read().decode() == file.read()
file.close()
return answer
with open(PYPI_DEFAULT_STATIC_PATH + "/test_pypi_server"
+ url_path) as file:
return response.read().decode() == file.read()
server = PyPIServer(static_uri_paths=["simple", "external"],
static_filesystem_paths=["test_pypi_server"])