Commit ec98cdc0 by Jake Bier Committed by Sébastien Eustace

Release file handles in tests (#324)

parent ceb48cd7
...@@ -47,8 +47,7 @@ def test_wheel_c_extension(): ...@@ -47,8 +47,7 @@ def test_wheel_c_extension():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "extended-0.1/build.py" in tar.getnames() assert "extended-0.1/build.py" in tar.getnames()
assert "extended-0.1/extended/extended.c" in tar.getnames() assert "extended-0.1/extended/extended.c" in tar.getnames()
...@@ -167,8 +166,7 @@ def test_module_src(): ...@@ -167,8 +166,7 @@ def test_module_src():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "module-src-0.1/src/module_src.py" in tar.getnames() assert "module-src-0.1/src/module_src.py" in tar.getnames()
whl = module_path / "dist" / "module_src-0.1-py2.py3-none-any.whl" whl = module_path / "dist" / "module_src-0.1-py2.py3-none-any.whl"
...@@ -192,8 +190,7 @@ def test_package_src(): ...@@ -192,8 +190,7 @@ def test_package_src():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "package-src-0.1/src/package_src/module.py" in tar.getnames() assert "package-src-0.1/src/package_src/module.py" in tar.getnames()
whl = module_path / "dist" / "package_src-0.1-py2.py3-none-any.whl" whl = module_path / "dist" / "package_src-0.1-py2.py3-none-any.whl"
......
...@@ -239,8 +239,7 @@ def test_package(): ...@@ -239,8 +239,7 @@ def test_package():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "my-package-1.2.3/LICENSE" in tar.getnames() assert "my-package-1.2.3/LICENSE" in tar.getnames()
...@@ -254,8 +253,7 @@ def test_module(): ...@@ -254,8 +253,7 @@ def test_module():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "module1-0.1/module1.py" in tar.getnames() assert "module1-0.1/module1.py" in tar.getnames()
...@@ -280,8 +278,7 @@ def test_with_c_extensions(): ...@@ -280,8 +278,7 @@ def test_with_c_extensions():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "extended-0.1/build.py" in tar.getnames() assert "extended-0.1/build.py" in tar.getnames()
assert "extended-0.1/extended/extended.c" in tar.getnames() assert "extended-0.1/extended/extended.c" in tar.getnames()
...@@ -307,8 +304,7 @@ def test_with_src_module_file(): ...@@ -307,8 +304,7 @@ def test_with_src_module_file():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "module-src-0.1/src/module_src.py" in tar.getnames() assert "module-src-0.1/src/module_src.py" in tar.getnames()
...@@ -333,8 +329,7 @@ def test_with_src_module_dir(): ...@@ -333,8 +329,7 @@ def test_with_src_module_dir():
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
assert "package-src-0.1/src/package_src/__init__.py" in tar.getnames() assert "package-src-0.1/src/package_src/__init__.py" in tar.getnames()
assert "package-src-0.1/src/package_src/module.py" in tar.getnames() assert "package-src-0.1/src/package_src/module.py" in tar.getnames()
...@@ -380,8 +375,7 @@ def test_package_with_include(mocker): ...@@ -380,8 +375,7 @@ def test_package_with_include(mocker):
assert sdist.exists() assert sdist.exists()
tar = tarfile.open(str(sdist), "r") with tarfile.open(str(sdist), "r") as tar:
names = tar.getnames() names = tar.getnames()
assert "with-include-1.2.3/LICENSE" in names assert "with-include-1.2.3/LICENSE" in names
assert "with-include-1.2.3/README.rst" in names assert "with-include-1.2.3/README.rst" in names
......
...@@ -35,8 +35,7 @@ def test_wheel_module(): ...@@ -35,8 +35,7 @@ def test_wheel_module():
assert whl.exists() assert whl.exists()
z = zipfile.ZipFile(str(whl)) with zipfile.ZipFile(str(whl)) as z:
assert "module1.py" in z.namelist() assert "module1.py" in z.namelist()
...@@ -48,8 +47,7 @@ def test_wheel_package(): ...@@ -48,8 +47,7 @@ def test_wheel_package():
assert whl.exists() assert whl.exists()
z = zipfile.ZipFile(str(whl)) with zipfile.ZipFile(str(whl)) as z:
assert "my_package/sub_pkg1/__init__.py" in z.namelist() assert "my_package/sub_pkg1/__init__.py" in z.namelist()
...@@ -70,8 +68,7 @@ def test_wheel_package_src(): ...@@ -70,8 +68,7 @@ def test_wheel_package_src():
assert whl.exists() assert whl.exists()
z = zipfile.ZipFile(str(whl)) with zipfile.ZipFile(str(whl)) as z:
assert "package_src/__init__.py" in z.namelist() assert "package_src/__init__.py" in z.namelist()
assert "package_src/module.py" in z.namelist() assert "package_src/module.py" in z.namelist()
...@@ -84,6 +81,5 @@ def test_wheel_module_src(): ...@@ -84,6 +81,5 @@ def test_wheel_module_src():
assert whl.exists() assert whl.exists()
z = zipfile.ZipFile(str(whl)) with zipfile.ZipFile(str(whl)) as z:
assert "module_src.py" in z.namelist() assert "module_src.py" in z.namelist()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment