@@ -86,8 +86,10 @@ def setUp(self):
8686
8787
8888# Except for python/mypy#731, prefer to define
89- # FilesDef = Dict[str, Union['FilesDef', str]]
90- FilesDef = Dict [str , Union [Dict [str , Union [Dict [str , str ], str ]], str ]]
89+ # FilesDef = Dict[str, Union['FilesDef', str, bytes]]
90+ FilesDef = Dict [
91+ str , Union [Dict [str , Union [Dict [str , Union [str , bytes ]], str , bytes ]], str , bytes ]
92+ ]
9193
9294
9395class DistInfoPkg (OnSysPath , SiteDir ):
@@ -214,6 +216,97 @@ def setUp(self):
214216 build_files (EggInfoPkg .files , prefix = self .site_dir )
215217
216218
219+ class EggInfoPkgPipInstalledNoToplevel (OnSysPath , SiteDir ):
220+ files : FilesDef = {
221+ "egg_with_module_pkg.egg-info" : {
222+ "PKG-INFO" : "Name: egg_with_module-pkg" ,
223+ # SOURCES.txt is made from the source archive, and contains files
224+ # (setup.py) that are not present after installation.
225+ "SOURCES.txt" : """
226+ egg_with_module.py
227+ setup.py
228+ egg_with_module_pkg.egg-info/PKG-INFO
229+ egg_with_module_pkg.egg-info/SOURCES.txt
230+ egg_with_module_pkg.egg-info/top_level.txt
231+ """ ,
232+ # installed-files.txt is written by pip, and is a strictly more
233+ # accurate source than SOURCES.txt as to the installed contents of
234+ # the package.
235+ "installed-files.txt" : """
236+ ../egg_with_module.py
237+ PKG-INFO
238+ SOURCES.txt
239+ top_level.txt
240+ """ ,
241+ # missing top_level.txt (to trigger fallback to installed-files.txt)
242+ },
243+ "egg_with_module.py" : """
244+ def main():
245+ print("hello world")
246+ """ ,
247+ }
248+
249+ def setUp (self ):
250+ super ().setUp ()
251+ build_files (EggInfoPkgPipInstalledNoToplevel .files , prefix = self .site_dir )
252+
253+
254+ class EggInfoPkgPipInstalledNoModules (OnSysPath , SiteDir ):
255+ files : FilesDef = {
256+ "egg_with_no_modules_pkg.egg-info" : {
257+ "PKG-INFO" : "Name: egg_with_no_modules-pkg" ,
258+ # SOURCES.txt is made from the source archive, and contains files
259+ # (setup.py) that are not present after installation.
260+ "SOURCES.txt" : """
261+ setup.py
262+ egg_with_no_modules_pkg.egg-info/PKG-INFO
263+ egg_with_no_modules_pkg.egg-info/SOURCES.txt
264+ egg_with_no_modules_pkg.egg-info/top_level.txt
265+ """ ,
266+ # installed-files.txt is written by pip, and is a strictly more
267+ # accurate source than SOURCES.txt as to the installed contents of
268+ # the package.
269+ "installed-files.txt" : """
270+ PKG-INFO
271+ SOURCES.txt
272+ top_level.txt
273+ """ ,
274+ # top_level.txt correctly reflects that no modules are installed
275+ "top_level.txt" : b"\n " ,
276+ },
277+ }
278+
279+ def setUp (self ):
280+ super ().setUp ()
281+ build_files (EggInfoPkgPipInstalledNoModules .files , prefix = self .site_dir )
282+
283+
284+ class EggInfoPkgSourcesFallback (OnSysPath , SiteDir ):
285+ files : FilesDef = {
286+ "sources_fallback_pkg.egg-info" : {
287+ "PKG-INFO" : "Name: sources_fallback-pkg" ,
288+ # SOURCES.txt is made from the source archive, and contains files
289+ # (setup.py) that are not present after installation.
290+ "SOURCES.txt" : """
291+ sources_fallback.py
292+ setup.py
293+ sources_fallback_pkg.egg-info/PKG-INFO
294+ sources_fallback_pkg.egg-info/SOURCES.txt
295+ """ ,
296+ # missing installed-files.txt (i.e. not installed by pip) and
297+ # missing top_level.txt (to trigger fallback to SOURCES.txt)
298+ },
299+ "sources_fallback.py" : """
300+ def main():
301+ print("hello world")
302+ """ ,
303+ }
304+
305+ def setUp (self ):
306+ super ().setUp ()
307+ build_files (EggInfoPkgSourcesFallback .files , prefix = self .site_dir )
308+
309+
217310class EggInfoFile (OnSysPath , SiteDir ):
218311 files : FilesDef = {
219312 "egginfo_file.egg-info" : """
0 commit comments