88)
99from ._tar import MemoryTarFile
1010from ._zip import MemoryZipFile
11+ from .metadata_contents import METADATA_CONTENTS
1112
1213
1314class ZipSdistTest (unittest .TestCase ):
@@ -94,10 +95,13 @@ def test_basic_metadata_absl_py_09(self) -> None:
9495 self .assertEqual ({"test" }, bm .provides_extra )
9596
9697 def test_basic_metadata_fields (self ) -> None :
98+ """
99+ Modern setuptools will drop a PKG-INFO file in a sdist that is very similar to the METADATA file in a wheel.
100+ """
97101 z = MemoryZipFile (
98102 {
99103 "foo/__init__.py" : b"" ,
100- "foo.egg-info/ PKG-INFO" :
b"Requires-Dist: foo \n Version: 1.2.58 \n Summary: Some Summary \n Home-page: http://example.com \n Author: Chicken \n Author-email: [email protected] \n Keywords: farm,animals \n Requires-Python: >=3.6 \n Description-Content-Type: text/markdown" ,
104+ "PKG-INFO" : METADATA_CONTENTS ,
101105 }
102106 )
103107 bm = basic_metadata_from_zip_sdist (z ) # type: ignore
@@ -109,7 +113,7 @@ def test_basic_metadata_fields(self) -> None:
109113 self .
assertEqual (
"[email protected] " ,
bm .
author_email )
110114 self .assertEqual ("farm,animals" , bm .keywords )
111115 self .assertEqual ("text/markdown" , bm .long_description_content_type )
112- self .assertEqual (None , bm .description )
116+ self .assertEqual ("# Foo \n \n A very important package. \n " , bm .description )
113117
114118
115119class TarSdistTest (unittest .TestCase ):
@@ -150,8 +154,8 @@ def test_basic_metadata(self) -> None:
150154
151155 def test_metadata_fields_from_tar_sdist (self ) -> None :
152156 t = MemoryTarFile (
153- ["foo.egg-info/ PKG-INFO" , "foo/__init__.py" ],
154- read_value = b"""Requires-Dist: foo \n Version: 1.2.58 \n Summary: Some Summary \n Home-page: http://example.com \n Author: Chicken \n Author-email: [email protected] \n Keywords: farm,animals \n Requires-Python: >=3.6 \n Description-Content-Type: text/markdown \n """ ,
157+ ["PKG-INFO" , "foo/__init__.py" ],
158+ read_value = METADATA_CONTENTS ,
155159 )
156160 bm = basic_metadata_from_tar_sdist (t ) # type: ignore
157161 self .assertEqual ("1.2.58" , bm .version )
@@ -161,4 +165,4 @@ def test_metadata_fields_from_tar_sdist(self) -> None:
161165 self .
assertEqual (
"[email protected] " ,
bm .
author_email )
162166 self .assertEqual ("farm,animals" , bm .keywords )
163167 self .assertEqual ("text/markdown" , bm .long_description_content_type )
164- self .assertEqual (None , bm .description )
168+ self .assertEqual ("# Foo \n \n A very important package. \n " , bm .description )
0 commit comments