Commit ec98cdc0 by Jake Bier Committed by Sébastien Eustace

Release file handles in tests (#324)

parent ceb48cd7
...@@ -47,10 +47,9 @@ def test_wheel_c_extension(): ...@@ -47,10 +47,9 @@ 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()
whl = list((module_path / "dist").glob("extended-0.1-cp*-cp*-*.whl"))[0] whl = list((module_path / "dist").glob("extended-0.1-cp*-cp*-*.whl"))[0]
...@@ -167,9 +166,8 @@ def test_module_src(): ...@@ -167,9 +166,8 @@ 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,9 +190,8 @@ def test_package_src(): ...@@ -192,9 +190,8 @@ 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,9 +239,8 @@ def test_package(): ...@@ -239,9 +239,8 @@ 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()
def test_module(): def test_module():
...@@ -254,9 +253,8 @@ def test_module(): ...@@ -254,9 +253,8 @@ 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()
def test_prelease(): def test_prelease():
...@@ -280,10 +278,9 @@ def test_with_c_extensions(): ...@@ -280,10 +278,9 @@ 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()
def test_with_src_module_file(): def test_with_src_module_file():
...@@ -307,9 +304,8 @@ def test_with_src_module_file(): ...@@ -307,9 +304,8 @@ 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()
def test_with_src_module_dir(): def test_with_src_module_dir():
...@@ -333,10 +329,9 @@ def test_with_src_module_dir(): ...@@ -333,10 +329,9 @@ 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()
def test_package_with_include(mocker): def test_package_with_include(mocker):
...@@ -380,21 +375,20 @@ def test_package_with_include(mocker): ...@@ -380,21 +375,20 @@ 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 assert "with-include-1.2.3/extra_dir/__init__.py" in names
assert "with-include-1.2.3/extra_dir/__init__.py" in names assert "with-include-1.2.3/extra_dir/vcs_excluded.txt" in names
assert "with-include-1.2.3/extra_dir/vcs_excluded.txt" in names assert "with-include-1.2.3/extra_dir/sub_pkg/__init__.py" in names
assert "with-include-1.2.3/extra_dir/sub_pkg/__init__.py" in names assert "with-include-1.2.3/extra_dir/sub_pkg/vcs_excluded.txt" not in names
assert "with-include-1.2.3/extra_dir/sub_pkg/vcs_excluded.txt" not in names assert "with-include-1.2.3/my_module.py" in names
assert "with-include-1.2.3/my_module.py" in names assert "with-include-1.2.3/notes.txt" in names
assert "with-include-1.2.3/notes.txt" in names assert "with-include-1.2.3/package_with_include/__init__.py" in names
assert "with-include-1.2.3/package_with_include/__init__.py" in names assert "with-include-1.2.3/pyproject.toml" in names
assert "with-include-1.2.3/pyproject.toml" in names assert "with-include-1.2.3/setup.py" in names
assert "with-include-1.2.3/setup.py" in names assert "with-include-1.2.3/PKG-INFO" in names
assert "with-include-1.2.3/PKG-INFO" in names
def test_proper_python_requires_if_single_version_specified(): def test_proper_python_requires_if_single_version_specified():
......
...@@ -35,9 +35,8 @@ def test_wheel_module(): ...@@ -35,9 +35,8 @@ 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()
def test_wheel_package(): def test_wheel_package():
...@@ -48,9 +47,8 @@ def test_wheel_package(): ...@@ -48,9 +47,8 @@ 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()
def test_wheel_prerelease(): def test_wheel_prerelease():
...@@ -70,10 +68,9 @@ def test_wheel_package_src(): ...@@ -70,10 +68,9 @@ 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()
def test_wheel_module_src(): def test_wheel_module_src():
...@@ -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