|
10 | 10 | import textwrap |
11 | 11 | import time |
12 | 12 |
|
| 13 | +from itertools import chain |
| 14 | + |
13 | 15 | import pytest |
14 | 16 |
|
15 | 17 | import mesonpy |
16 | 18 |
|
17 | | -from .conftest import in_git_repo_context |
| 19 | +from .conftest import in_git_repo_context, metadata |
18 | 20 |
|
19 | 21 |
|
20 | 22 | def test_no_pep621(sdist_library): |
21 | 23 | with tarfile.open(sdist_library, 'r:gz') as sdist: |
22 | | - sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read().decode() |
| 24 | + sdist_pkg_info = sdist.extractfile('library-1.0.0/PKG-INFO').read() |
23 | 25 |
|
24 | | - assert sdist_pkg_info == textwrap.dedent('''\ |
| 26 | + assert metadata(sdist_pkg_info) == metadata(textwrap.dedent('''\ |
25 | 27 | Metadata-Version: 2.1 |
26 | 28 | Name: library |
27 | 29 | Version: 1.0.0 |
28 | | - ''') |
| 30 | + ''')) |
29 | 31 |
|
30 | 32 |
|
31 | 33 | def test_pep621(sdist_full_metadata): |
32 | 34 | with tarfile.open(sdist_full_metadata, 'r:gz') as sdist: |
33 | | - sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read().decode() |
| 35 | + sdist_pkg_info = sdist.extractfile('full_metadata-1.2.3/PKG-INFO').read() |
| 36 | + |
| 37 | + meta = metadata(sdist_pkg_info) |
34 | 38 |
|
35 | | - metadata = textwrap.dedent('''\ |
| 39 | + # pyproject-metadata prior to 0.9.0 strips trailing newlines |
| 40 | + meta['license'] = meta['license'].rstrip() |
| 41 | + |
| 42 | + assert meta == metadata(textwrap.dedent('''\ |
36 | 43 | Metadata-Version: 2.1 |
37 | 44 | Name: full-metadata |
38 | 45 | Version: 1.2.3 |
@@ -67,20 +74,18 @@ def test_pep621(sdist_full_metadata): |
67 | 74 | # full-metadata |
68 | 75 |
|
69 | 76 | An example package with all of the PEP 621 metadata! |
70 | | - ''') |
71 | | - |
72 | | - assert sdist_pkg_info == metadata |
| 77 | + ''')) |
73 | 78 |
|
74 | 79 |
|
75 | 80 | def test_dynamic_version(sdist_dynamic_version): |
76 | 81 | with tarfile.open(sdist_dynamic_version, 'r:gz') as sdist: |
77 | | - sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read().decode() |
| 82 | + sdist_pkg_info = sdist.extractfile('dynamic_version-1.0.0/PKG-INFO').read() |
78 | 83 |
|
79 | | - assert sdist_pkg_info == textwrap.dedent('''\ |
| 84 | + assert metadata(sdist_pkg_info) == metadata(textwrap.dedent('''\ |
80 | 85 | Metadata-Version: 2.1 |
81 | 86 | Name: dynamic-version |
82 | 87 | Version: 1.0.0 |
83 | | - ''') |
| 88 | + ''')) |
84 | 89 |
|
85 | 90 |
|
86 | 91 | def test_contents(sdist_library): |
|
0 commit comments