Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with pyproject-metadata >= 0.8.0rc1 #619

Closed
mgorny opened this issue Apr 17, 2024 · 1 comment
Closed

Test failures with pyproject-metadata >= 0.8.0rc1 #619

mgorny opened this issue Apr 17, 2024 · 1 comment

Comments

@mgorny
Copy link
Contributor

mgorny commented Apr 17, 2024

I know it's a bit early but Gentoo ended up needing it because of pdm-metadata (sigh). I'll submit a PR to future-proof the test suite. Hope you don't mind.

FWICS it's roughly a mismatch of exception message, and use of comma instead of space in Keywords (apparently the former is correct).

============================================================== FAILURES ===============================================================
________________________________________________________ test_missing_version _________________________________________________________

package_missing_version = PosixPath('/tmp/meson-python/tests/packages/missing-version')

    def test_missing_version(package_missing_version):
        pyproject = {'project': {
            'name': 'missing-version',
        }}
        with pytest.raises(pyproject_metadata.ConfigurationError, match='Required "project.version" field is missing'):
>           Metadata.from_pyproject(pyproject, pathlib.Path())

/tmp/meson-python/tests/test_metadata.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/meson-python/mesonpy/__init__.py:256: in from_pyproject
    metadata = super().from_pyproject(data, project_dir)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'mesonpy.Metadata'>, data = {'project': {'name': 'missing-version'}}, project_dir = PosixPath('.')
metadata_version = None

    @classmethod
    def from_pyproject(
        cls,
        data: Mapping[str, Any],
        project_dir: str | os.PathLike[str] = os.path.curdir,
        metadata_version: str | None = None,
    ) -> Self:
        fetcher = DataFetcher(data)
        project_dir = pathlib.Path(project_dir)
    
        if 'project' not in fetcher:
            msg = 'Section "project" missing in pyproject.toml'
            raise ConfigurationError(msg)
    
        dynamic = fetcher.get_list('project.dynamic')
        if 'name' in dynamic:
            msg = 'Unsupported field "name" in "project.dynamic"'
            raise ConfigurationError(msg)
    
        for field in dynamic:
            if field in data['project']:
                msg = f'Field "project.{field}" declared as dynamic in "project.dynamic" but is defined'
                raise ConfigurationError(msg)
    
        name = fetcher.get_str('project.name')
        if not name:
            msg = 'Field "project.name" missing'
            raise ConfigurationError(msg)
    
        version_string = fetcher.get_str('project.version')
        requires_python_string = fetcher.get_str('project.requires-python')
        version = packaging.version.Version(version_string) if version_string else None
    
        if version is None and 'version' not in dynamic:
            msg = 'Field "project.version" missing and "version" not specified in "project.dynamic"'
>           raise ConfigurationError(msg)
E           pyproject_metadata.ConfigurationError: Field "project.version" missing and "version" not specified in "project.dynamic"

/tmp/meson-python/.venv/lib/pypy3.10/site-packages/pyproject_metadata/__init__.py:242: ConfigurationError

During handling of the above exception, another exception occurred:

package_missing_version = PosixPath('/tmp/meson-python/tests/packages/missing-version')

    def test_missing_version(package_missing_version):
        pyproject = {'project': {
            'name': 'missing-version',
        }}
>       with pytest.raises(pyproject_metadata.ConfigurationError, match='Required "project.version" field is missing'):
E       AssertionError: Regex pattern did not match.
E        Regex: 'Required "project.version" field is missing'
E        Input: 'Field "project.version" missing and "version" not specified in "project.dynamic"'

/tmp/meson-python/tests/test_metadata.py:51: AssertionError
_____________________________________________________________ test_pep621 _____________________________________________________________

sdist_full_metadata = PosixPath('/tmp/pytest-of-mgorny/pytest-4/test0/mesonpy-test-rsnkxc7e/full_metadata-1.2.3.tar.gz')

    def test_pep621(sdist_full_metadata):
        with tarfile.open(sdist_full_metadata, 'r:gz') as sdist:
            sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read().decode()
    
>       assert sdist_pkg_info == textwrap.dedent('''\
            Metadata-Version: 2.1
            Name: full-metadata
            Version: 1.2.3
            Summary: Some package with all of the PEP 621 metadata
            Keywords: full metadata
            Home-page: https://example.com
            Author: Jane Doe
            Author-Email: Unknown <jhon.doe@example.com>
            Maintainer-Email: Jane Doe <jane.doe@example.com>
            License: some license
            Classifier: Development Status :: 4 - Beta
            Classifier: Programming Language :: Python
            Project-URL: Homepage, https://example.com
            Project-URL: Documentation, https://readthedocs.org
            Project-URL: Repository, https://github.com/mesonbuild/meson-python
            Project-URL: Changelog, https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
            Requires-Python: >=3.7
            Requires-Dist: a
            Requires-Dist: b>1
            Requires-Dist: c>2; os_name != "nt"
            Requires-Dist: d<3; extra == "test"
            Requires-Dist: e[all]; extra == "test"
            Provides-Extra: test
            Description-Content-Type: text/markdown
    
            <!--
            SPDX-FileCopyrightText: 2021 The meson-python developers
    
            SPDX-License-Identifier: MIT
            -->
    
            # full-metadata
    
            An example package with all of the PEP 621 metadata!
        ''')
E       AssertionError: assert 'Metadata-Ver...1 metadata!\n' == 'Metadata-Ver...1 metadata!\n'
E         
E         Skipping 116 identical leading characters in diff, use -v to show
E         Skipping 906 identical trailing characters in diff, use -v to show
E         - ords: full metadata
E         ?           ^
E         + ords: full,metadata
E         ?           ^

tests/test_sdist.py:33: AssertionError
-------------------------------------------------------- Captured stdout setup --------------------------------------------------------
Initialized empty Git repository in /tmp/meson-python/tests/packages/full-metadata/.git/
+ meson setup /tmp/meson-python/tests/packages/full-metadata /tmp/meson-python/tests/packages/full-metadata/.mesonpy-777vl431 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/meson-python/tests/packages/full-metadata/.mesonpy-777vl431/meson-python-native-file.ini
The Meson build system
Version: 1.4.0
Source dir: /tmp/meson-python/tests/packages/full-metadata
Build dir: /tmp/meson-python/tests/packages/full-metadata/.mesonpy-777vl431
Build type: native build
Project name: full-metadata
Project version: 1.0.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 0

full-metadata 1.0.0

  User defined options
    Native files: /tmp/meson-python/tests/packages/full-metadata/.mesonpy-777vl431/meson-python-native-file.ini
    buildtype   : release
    b_ndebug    : if-release
    b_vscrt     : md

Found ninja-1.12.0 at /usr/bin/ninja
+ meson dist --allow-dirty --no-tests --formats gztar
Created /tmp/meson-python/tests/packages/full-metadata/.mesonpy-777vl431/meson-dist/full-metadata-1.0.0.tar.gz
@mgorny
Copy link
Contributor Author

mgorny commented Apr 17, 2024

Ah, sorry, now I see there's #612 for it already. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants