Skip to content

test_apply_pyproject_equivalent_to_setuptcfg is flaky #5284

Description

@jaraco

Recently, I've noticed that test_apply_pyproject_equivalent_to_setupcfg will fail but then succeed on a retry. Here's an example run from a distutils test:

=================================== FAILURES ===================================
_ test_apply_pyproject_equivalent_to_setupcfg[https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg] _
[gw0] linux -- Python 3.10.20 /home/runner/work/distutils/distutils/integration/setuptools/.tox/py/bin/python

url = 'https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg'
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f6477d612d0>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw0/test_apply_pyproject_equivalen10')

    @pytest.mark.parametrize("url", urls_from_file(HERE / EXAMPLES_FILE))
    @pytest.mark.filterwarnings("ignore")
    @pytest.mark.uses_network
    def test_apply_pyproject_equivalent_to_setupcfg(url, monkeypatch, tmp_path):
        monkeypatch.setattr(expand, "read_attr", Mock(return_value="0.0.1"))
        monkeypatch.setattr(
            Distribution, "_expand_patterns", Mock(side_effect=_mock_expand_patterns)
        )
        setupcfg_example = retrieve_file(url)
        pyproject_example = Path(tmp_path, "pyproject.toml")
        setupcfg_text = setupcfg_example.read_text(encoding="utf-8")
        toml_config = LiteTranslator().translate(setupcfg_text, "setup.cfg")
        pyproject_example.write_text(toml_config, encoding="utf-8")
    
>       dist_toml = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject_example)

setuptools/tests/config/test_apply_pyprojecttoml.py:63: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
setuptools/config/pyprojecttoml.py:72: in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
setuptools/config/pyprojecttoml.py:149: in read_configuration
    validate(subset, filepath)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

config = {'project': {'dynamic': ['version']}, 'tool': {'setuptools': {'include-package-data': False}}}
filepath = '/tmp/pytest-of-runner/pytest-0/popen-gw0/test_apply_pyproject_equivalen10/pyproject.toml'

    def validate(config: dict, filepath: StrPath) -> bool:
        from . import _validate_pyproject as validator
    
        trove_classifier = validator.FORMAT_FUNCTIONS.get("trove-classifier")
        if hasattr(trove_classifier, "_disable_download"):
            # Improve reproducibility by default. See abravalheri/validate-pyproject#31
            trove_classifier._disable_download()  # type: ignore[union-attr]
    
        try:
            return validator.validate(config)
        except validator.ValidationError as ex:
            summary = f"configuration error: {ex.summary}"
            if ex.name.strip("`") != "project":
                # Probably it is just a field missing/misnamed, not worthy the verbosity...
                _logger.debug(summary)
                _logger.debug(ex.details)
    
            error = f"invalid pyproject.toml config: {ex.name}."
>           raise ValueError(f"{error}\n{summary}") from None
E           ValueError: invalid pyproject.toml config: `project`.
E           configuration error: `project` must contain ['name'] properties

setuptools/config/pyprojecttoml.py:61: ValueError
----------------------------- Captured stdout call -----------------------------
Downloading https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg to /home/runner/work/distutils/distutils/integration/setuptools/setuptools/tests/config/downloads/sqlalchemy_sqlalchemy533f5718904b620be8d63f2474229945d6f8ba5d_setup.cfg

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions