1515
1616import mesonpy
1717
18- from .conftest import in_git_repo_context
18+ from .conftest import in_git_repo_context , metadata
1919
2020
2121def test_no_pep621 (sdist_library ):
2222 with tarfile .open (sdist_library , 'r:gz' ) as sdist :
23- sdist_pkg_info = sdist .extractfile ('library-1.0.0/PKG-INFO' ).read (). decode ()
23+ sdist_pkg_info = sdist .extractfile ('library-1.0.0/PKG-INFO' ).read ()
2424
25- assert sdist_pkg_info == textwrap .dedent ('''\
25+ assert metadata ( sdist_pkg_info ) == metadata ( textwrap .dedent ('''\
2626 Metadata-Version: 2.1
2727 Name: library
2828 Version: 1.0.0
29- ''' )
29+ ''' ))
3030
3131
3232def test_pep621 (sdist_full_metadata ):
3333 with tarfile .open (sdist_full_metadata , 'r:gz' ) as sdist :
34- sdist_pkg_info = sdist .extractfile ('full_metadata-1.2.3/PKG-INFO' ).read ().decode ()
34+ sdist_pkg_info = sdist .extractfile ('full_metadata-1.2.3/PKG-INFO' ).read ()
35+
36+ meta = metadata (sdist_pkg_info )
37+
38+ # pyproject-metadata prior to 0.9.0 strips trailing newlines
39+ meta ['license' ] = meta ['license' ].rstrip ()
3540
36- metadata = re .escape (textwrap .dedent ('''\
41+ # pyproject-metadata 0.9.0 and later does not emit Home-Page
42+ meta .pop ('home_page' , None )
43+ # nor normalizes Project-URL keys
44+ meta ['project_urls' ] = {k .lower (): v for k , v in meta ['project_urls' ].items ()}
45+
46+ assert meta == metadata (textwrap .dedent ('''\
3747 Metadata-Version: 2.1
3848 Name: full-metadata
3949 Version: 1.2.3
4050 Summary: Some package with all of the PEP 621 metadata
41- Keywords: full metadata
42- Home-page: https://example.com
51+ Keywords: full,metadata,keyword with spaces
4352 Author: Jane Doe
4453 Author-Email: Unknown <[email protected] > 4554 Maintainer-Email: Jane Doe <[email protected] > 4655 License: some license
4756 Classifier: Development Status :: 4 - Beta
4857 Classifier: Programming Language :: Python
49- Project-URL: Homepage , https://example.com
50- Project-URL: Documentation , https://readthedocs.org
51- Project-URL: Repository , https://github.com/mesonbuild/meson-python
52- Project-URL: Changelog , https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
58+ Project-URL: homepage , https://example.com
59+ Project-URL: documentation , https://readthedocs.org
60+ Project-URL: repository , https://github.com/mesonbuild/meson-python
61+ Project-URL: changelog , https://github.com/mesonbuild/meson-python/blob/master/CHANGELOG.rst
5362 Requires-Python: >=3.7
5463 Requires-Dist: a
5564 Requires-Dist: b>1
@@ -70,20 +79,16 @@ def test_pep621(sdist_full_metadata):
7079 An example package with all of the PEP 621 metadata!
7180 ''' ))
7281
73- # pyproject-metadata 0.8.0 and later uses a comma to separate keywords
74- expr = metadata .replace (r'Keywords:\ full\ metadata' , r'Keywords:\ full[ ,]metadata' )
75- assert re .fullmatch (expr , sdist_pkg_info )
76-
7782
7883def test_dynamic_version (sdist_dynamic_version ):
7984 with tarfile .open (sdist_dynamic_version , 'r:gz' ) as sdist :
80- sdist_pkg_info = sdist .extractfile ('dynamic_version-1.0.0/PKG-INFO' ).read (). decode ()
85+ sdist_pkg_info = sdist .extractfile ('dynamic_version-1.0.0/PKG-INFO' ).read ()
8186
82- assert sdist_pkg_info == textwrap .dedent ('''\
87+ assert metadata ( sdist_pkg_info ) == metadata ( textwrap .dedent ('''\
8388 Metadata-Version: 2.1
8489 Name: dynamic-version
8590 Version: 1.0.0
86- ''' )
91+ ''' ))
8792
8893
8994def test_contents (sdist_library ):
0 commit comments