2012-08-10 14:47:54 -03:00
|
|
|
from importlib import machinery
|
2009-01-29 20:22:35 -04:00
|
|
|
from .. import abc
|
2009-02-06 22:06:43 -04:00
|
|
|
from . import util
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
2013-10-25 13:33:59 -03:00
|
|
|
class FinderTests(unittest.TestCase, abc.FinderTests):
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
"""Test the finder for extension modules."""
|
|
|
|
|
|
|
|
def find_module(self, fullname):
|
2012-08-10 14:47:54 -03:00
|
|
|
importer = machinery.FileFinder(util.PATH,
|
|
|
|
(machinery.ExtensionFileLoader,
|
|
|
|
machinery.EXTENSION_SUFFIXES))
|
2009-01-17 20:24:28 -04:00
|
|
|
return importer.find_module(fullname)
|
|
|
|
|
2009-01-26 21:33:54 -04:00
|
|
|
def test_module(self):
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(self.find_module(util.NAME))
|
2009-01-17 20:24:28 -04:00
|
|
|
|
2009-01-26 21:33:54 -04:00
|
|
|
def test_package(self):
|
2012-08-10 14:47:54 -03:00
|
|
|
# No extension module as an __init__ available for testing.
|
2009-01-26 21:33:54 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
def test_module_in_package(self):
|
|
|
|
# No extension module in a package available for testing.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_package_in_package(self):
|
2012-08-10 14:47:54 -03:00
|
|
|
# No extension module as an __init__ available for testing.
|
2009-01-26 21:33:54 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
def test_package_over_module(self):
|
|
|
|
# Extension modules cannot be an __init__ for a package.
|
|
|
|
pass
|
|
|
|
|
2009-01-17 20:24:28 -04:00
|
|
|
def test_failure(self):
|
2012-06-28 07:15:01 -03:00
|
|
|
self.assertIsNone(self.find_module('asdfjkl;'))
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
from test.support import run_unittest
|
|
|
|
run_unittest(FinderTests)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|