Skip to content

Commit

Permalink
TST: Adapt to changes in pyproject-metadata 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi committed Apr 15, 2024
1 parent 18981b3 commit ba14bfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT

import pathlib
import re

import packaging.version
import pyproject_metadata
Expand Down Expand Up @@ -48,5 +49,10 @@ 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'):
match = '|'.join((
re.escape('Required "project.version" field is missing'),
# pyproject-metatadata 0.8.0 and later
re.escape('Field "project.version" missing and "version" not specified in "project.dynamic"'),
))
with pytest.raises(pyproject_metadata.ConfigurationError, match=match):
Metadata.from_pyproject(pyproject, pathlib.Path())
9 changes: 7 additions & 2 deletions tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MIT

import os
import re
import stat
import sys
import tarfile
Expand Down Expand Up @@ -30,7 +31,7 @@ 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 = re.escape(textwrap.dedent('''\
Metadata-Version: 2.1
Name: full-metadata
Version: 1.2.3
Expand Down Expand Up @@ -65,7 +66,11 @@ def test_pep621(sdist_full_metadata):
# full-metadata
An example package with all of the PEP 621 metadata!
''')
'''))

# pyproject-metadata 0.8.0 and later uses a comma to separate keywords
expr = metadata.replace(r'Keywords:\ full\ metadata', r'Keywords:\ full[ ,]metadata')
assert re.fullmatch(expr, sdist_pkg_info)


def test_dynamic_version(sdist_dynamic_version):
Expand Down

0 comments on commit ba14bfd

Please sign in to comment.