88)
99from ._tar import MemoryTarFile
1010from ._zip import MemoryZipFile
11+ from .metadata_contents import METADATA_CONTENTS
1112
1213
1314class ZipSdistTest (unittest .TestCase ):
1415 def test_requires_as_expected (self ) -> None :
1516 z = MemoryZipFile (
1617 {
1718 "foo/__init__.py" : b"" ,
19+ "foo.egg-info/PKG-INFO" : b"\n " ,
1820 "foo.egg-info/requires.txt" : b"""\
1921 a
2022[e]
@@ -36,6 +38,7 @@ def test_basic_metadata(self) -> None:
3638 z = MemoryZipFile (
3739 {
3840 "foo/__init__.py" : b"" ,
41+ "foo.egg-info/PKG-INFO" : b"\n " ,
3942 "foo.egg-info/requires.txt" : b"""\
4043 a
4144[e]
@@ -68,6 +71,7 @@ def test_basic_metadata_absl_py_09(self) -> None:
6871 z = MemoryZipFile (
6972 {
7073 "foo/__init__.py" : b"" ,
74+ "foo.egg-info/PKG-INFO" : b"\n " ,
7175 "foo.egg-info/requires.txt" : b"""\
7276 six
7377
@@ -90,11 +94,32 @@ def test_basic_metadata_absl_py_09(self) -> None:
9094 )
9195 self .assertEqual ({"test" }, bm .provides_extra )
9296
97+ 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+ """
101+ z = MemoryZipFile (
102+ {
103+ "foo/__init__.py" : b"" ,
104+ "PKG-INFO" : METADATA_CONTENTS ,
105+ }
106+ )
107+ bm = basic_metadata_from_zip_sdist (z ) # type: ignore
108+ self .assertEqual (["foo" ], bm .reqs )
109+ self .assertEqual ("1.2.58" , bm .version )
110+ self .assertEqual ("Some Summary" , bm .summary )
111+ self .assertEqual ("http://example.com" , bm .url )
112+ self .assertEqual ("Chicken" , bm .author )
113+ self .
assertEqual (
"[email protected] " ,
bm .
author_email )
114+ self .assertEqual ("farm,animals" , bm .keywords )
115+ self .assertEqual ("text/markdown" , bm .long_description_content_type )
116+ self .assertEqual ("# Foo\n \n A very important package.\n " , bm .description )
117+
93118
94119class TarSdistTest (unittest .TestCase ):
95120 def test_requires_as_expected (self ) -> None :
96121 t = MemoryTarFile (
97- ["foo.egg-info/requires.txt" , "foo/__init__.py" ],
122+ ["foo.egg-info/PKG-INFO" , "foo.egg-info/ requires.txt" , "foo/__init__.py" ],
98123 read_value = b"""\
99124 a
100125[e]
@@ -113,7 +138,7 @@ def test_requires_as_expected(self) -> None:
113138
114139 def test_basic_metadata (self ) -> None :
115140 t = MemoryTarFile (
116- ["foo.egg-info/requires.txt" , "foo/__init__.py" ],
141+ ["foo.egg-info/PKG-INFO" , "foo.egg-info/ requires.txt" , "foo/__init__.py" ],
117142 read_value = b"""\
118143 a
119144[e]
@@ -126,3 +151,18 @@ def test_basic_metadata(self) -> None:
126151 bm .reqs ,
127152 )
128153 self .assertEqual ({"e" }, bm .provides_extra )
154+
155+ def test_metadata_fields_from_tar_sdist (self ) -> None :
156+ t = MemoryTarFile (
157+ ["PKG-INFO" , "foo/__init__.py" ],
158+ read_value = METADATA_CONTENTS ,
159+ )
160+ bm = basic_metadata_from_tar_sdist (t ) # type: ignore
161+ self .assertEqual ("1.2.58" , bm .version )
162+ self .assertEqual ("Some Summary" , bm .summary )
163+ self .assertEqual ("http://example.com" , bm .url )
164+ self .assertEqual ("Chicken" , bm .author )
165+ self .
assertEqual (
"[email protected] " ,
bm .
author_email )
166+ self .assertEqual ("farm,animals" , bm .keywords )
167+ self .assertEqual ("text/markdown" , bm .long_description_content_type )
168+ self .assertEqual ("# Foo\n \n A very important package.\n " , bm .description )
0 commit comments