Home | History | Annotate | Download | only in extension
      1 from .. import abc
      2 from .. import util
      3 
      4 machinery = util.import_importlib('importlib.machinery')
      5 
      6 import unittest
      7 import warnings
      8 
      9 
     10 class FinderTests(abc.FinderTests):
     11 
     12     """Test the finder for extension modules."""
     13 
     14     def find_module(self, fullname):
     15         importer = self.machinery.FileFinder(util.EXTENSIONS.path,
     16                                             (self.machinery.ExtensionFileLoader,
     17                                              self.machinery.EXTENSION_SUFFIXES))
     18         with warnings.catch_warnings():
     19             warnings.simplefilter('ignore', DeprecationWarning)
     20             return importer.find_module(fullname)
     21 
     22     def test_module(self):
     23         self.assertTrue(self.find_module(util.EXTENSIONS.name))
     24 
     25     # No extension module as an __init__ available for testing.
     26     test_package = test_package_in_package = None
     27 
     28     # No extension module in a package available for testing.
     29     test_module_in_package = None
     30 
     31     # Extension modules cannot be an __init__ for a package.
     32     test_package_over_module = None
     33 
     34     def test_failure(self):
     35         self.assertIsNone(self.find_module('asdfjkl;'))
     36 
     37 
     38 (Frozen_FinderTests,
     39  Source_FinderTests
     40  ) = util.test_both(FinderTests, machinery=machinery)
     41 
     42 
     43 if __name__ == '__main__':
     44     unittest.main()
     45