summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/test_pypi_server.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
commit21a9c748aa8698c8201e30a58320d587f6bb7540 (patch)
treeddfcb60a800bc010237ee750a449c4639e5515e3 /Lib/packaging/tests/test_pypi_server.py
parent0e3f3a70760f5ef1c0d1f7baf55046514b6bfbb6 (diff)
downloadcpython-21a9c748aa8698c8201e30a58320d587f6bb7540.zip
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.gz
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.bz2
packaging: use with open() instead of try/finally: close
Diffstat (limited to 'Lib/packaging/tests/test_pypi_server.py')
-rw-r--r--Lib/packaging/tests/test_pypi_server.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/packaging/tests/test_pypi_server.py b/Lib/packaging/tests/test_pypi_server.py
index 1fcbdcb..2c4ec0d 100644
--- a/Lib/packaging/tests/test_pypi_server.py
+++ b/Lib/packaging/tests/test_pypi_server.py
@@ -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"])