@@ -155,6 +155,28 @@ def main_gui(): pass
155155def main_tomatoes(): pass
156156"""
157157
158+ PEP639_LICENSE_TEXT = """\
159+ [project]
160+ name = "spam"
161+ version = "2020.0.0"
162+ authors = [
163+ 164+ {name = "Tzu-Ping Chung"}
165+ ]
166+ license = {text = "MIT"}
167+ """
168+
169+ PEP639_LICENSE_EXPRESSION = """\
170+ [project]
171+ name = "spam"
172+ version = "2020.0.0"
173+ authors = [
174+ 175+ {name = "Tzu-Ping Chung"}
176+ ]
177+ license = "MIT"
178+ """
179+
158180
159181def _pep621_example_project (
160182 tmp_path ,
@@ -250,6 +272,47 @@ def test_utf8_maintainer_in_metadata( # issue-3663
250272 assert f"Maintainer-email: { expected_maintainers_meta_value } " in content
251273
252274
275+ @pytest .mark .parametrize (
276+ ('pyproject_text' , 'license' , 'license_expression' , 'content_str' ),
277+ (
278+ pytest .param (
279+ PEP639_LICENSE_TEXT ,
280+ 'MIT' ,
281+ None ,
282+ 'License: MIT' ,
283+ id = 'license-text' ,
284+ ),
285+ pytest .param (
286+ PEP639_LICENSE_EXPRESSION ,
287+ None ,
288+ 'MIT' ,
289+ 'License-Expression: MIT' ,
290+ id = 'license-expression' ,
291+ ),
292+ ),
293+ )
294+ def test_license_in_metadata (
295+ license ,
296+ license_expression ,
297+ content_str ,
298+ pyproject_text ,
299+ tmp_path ,
300+ ):
301+ pyproject = _pep621_example_project (
302+ tmp_path ,
303+ "README" ,
304+ pyproject_text = pyproject_text ,
305+ )
306+ dist = pyprojecttoml .apply_configuration (makedist (tmp_path ), pyproject )
307+ assert dist .metadata .license == license
308+ assert dist .metadata .license_expression == license_expression
309+ pkg_file = tmp_path / "PKG-FILE"
310+ with open (pkg_file , "w" , encoding = "utf-8" ) as fh :
311+ dist .metadata .write_pkg_file (fh )
312+ content = pkg_file .read_text (encoding = "utf-8" )
313+ assert content_str in content
314+
315+
253316class TestLicenseFiles :
254317 # TODO: After PEP 639 is accepted, we have to move the license-files
255318 # to the `project` table instead of `tool.setuptools`
0 commit comments