Skip to content

Commit

Permalink
Add metatest to make sure auxiliary file is properly packaged
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Apr 1, 2022
1 parent f54ec14 commit d829e0b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -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 ---


Expand Down

0 comments on commit d829e0b

Please sign in to comment.