(root)/
Python-3.11.7/
Lib/
test/
test_importlib/
test_zip.py
       1  import sys
       2  import unittest
       3  
       4  from . import fixtures
       5  from importlib.metadata import (
       6      PackageNotFoundError,
       7      distribution,
       8      distributions,
       9      entry_points,
      10      files,
      11      version,
      12  )
      13  
      14  
      15  class ESC[4;38;5;81mTestZip(ESC[4;38;5;149mfixturesESC[4;38;5;149m.ESC[4;38;5;149mZipFixtures, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      16      def setUp(self):
      17          super().setUp()
      18          self._fixture_on_path('example-21.12-py3-none-any.whl')
      19  
      20      def test_zip_version(self):
      21          self.assertEqual(version('example'), '21.12')
      22  
      23      def test_zip_version_does_not_match(self):
      24          with self.assertRaises(PackageNotFoundError):
      25              version('definitely-not-installed')
      26  
      27      def test_zip_entry_points(self):
      28          scripts = entry_points(group='console_scripts')
      29          entry_point = scripts['example']
      30          self.assertEqual(entry_point.value, 'example:main')
      31          entry_point = scripts['Example']
      32          self.assertEqual(entry_point.value, 'example:main')
      33  
      34      def test_missing_metadata(self):
      35          self.assertIsNone(distribution('example').read_text('does not exist'))
      36  
      37      def test_case_insensitive(self):
      38          self.assertEqual(version('Example'), '21.12')
      39  
      40      def test_files(self):
      41          for file in files('example'):
      42              path = str(file.dist.locate_file(file))
      43              assert '.whl/' in path, path
      44  
      45      def test_one_distribution(self):
      46          dists = list(distributions(path=sys.path[:1]))
      47          assert len(dists) == 1
      48  
      49  
      50  class ESC[4;38;5;81mTestEgg(ESC[4;38;5;149mTestZip):
      51      def setUp(self):
      52          super().setUp()
      53          self._fixture_on_path('example-21.12-py3.6.egg')
      54  
      55      def test_files(self):
      56          for file in files('example'):
      57              path = str(file.dist.locate_file(file))
      58              assert '.egg/' in path, path
      59  
      60      def test_normalized_name(self):
      61          dist = distribution('example')
      62          assert dist._normalized_name == 'example'