diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index b822096363..ec9f602d33 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -3,9 +3,11 @@ """ import io import re +import tarfile from pathlib import Path from urllib.request import urlopen from unittest.mock import Mock +from zipfile import ZipFile import pytest from ini2toml.api import Translator @@ -18,7 +20,8 @@ from setuptools.command.egg_info import write_requirements -EXAMPLES = (Path(__file__).parent / "setupcfg_examples.txt").read_text() +EXAMPLES_FILE = "setupcfg_examples.txt" +EXAMPLES = (Path(__file__).parent / EXAMPLES_FILE).read_text() EXAMPLE_URLS = [x for x in EXAMPLES.splitlines() if not x.startswith("#")] DOWNLOAD_DIR = Path(__file__).parent / "downloads" @@ -276,6 +279,18 @@ def test_optional_dependencies_dont_remove_env_markers(self, tmp_path): assert "bar" in reqs +class TestMeta: + def test_example_file_in_sdist(self, setuptools_sdist): + """Meta test to ensure tests can run from sdist""" + with tarfile.open(setuptools_sdist) as tar: + assert any(name.endswith(EXAMPLES_FILE) for name in tar.getnames()) + + def test_example_file_not_in_wheel(self, setuptools_wheel): + """Meta test to ensure auxiliary test files are not in wheel""" + with ZipFile(setuptools_wheel) as zipfile: + assert not any(name.endswith(EXAMPLES_FILE) for name in zipfile.namelist()) + + # --- Auxiliary Functions ---