| 
									
										
										
										
											2009-01-22 22:43:07 +00:00
										 |  |  | from importlib import machinery | 
					
						
							| 
									
										
										
										
											2009-01-30 00:22:35 +00:00
										 |  |  | from .. import abc | 
					
						
							| 
									
										
										
										
											2009-02-01 04:00:05 +00:00
										 |  |  | from .. import util | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | import sys | 
					
						
							|  |  |  | import unittest | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-30 00:22:35 +00:00
										 |  |  | class FinderTests(abc.FinderTests): | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     """Test find_module() for built-in modules.""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert 'errno' in sys.builtin_module_names | 
					
						
							|  |  |  |     name = 'errno' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-27 01:41:57 +00:00
										 |  |  |     def test_module(self): | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  |         # Common case. | 
					
						
							| 
									
										
										
										
											2009-02-01 04:00:05 +00:00
										 |  |  |         with util.uncache(self.name): | 
					
						
							| 
									
										
										
										
											2009-01-27 01:41:57 +00:00
										 |  |  |             self.assert_(machinery.BuiltinImporter.find_module(self.name)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_package(self): | 
					
						
							|  |  |  |         # Built-in modules cannot be a package. | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_module_in_package(self): | 
					
						
							|  |  |  |         # Built-in modules cannobt be in a package. | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_package_in_package(self): | 
					
						
							|  |  |  |         # Built-in modules cannot be a package. | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_package_over_module(self): | 
					
						
							|  |  |  |         # Built-in modules cannot be a package. | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def test_failure(self): | 
					
						
							|  |  |  |         assert 'importlib' not in sys.builtin_module_names | 
					
						
							|  |  |  |         loader = machinery.BuiltinImporter.find_module('importlib') | 
					
						
							|  |  |  |         self.assert_(loader is None) | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def test_ignore_path(self): | 
					
						
							|  |  |  |         # The value for 'path' should always trigger a failed import. | 
					
						
							| 
									
										
										
										
											2009-02-01 04:00:05 +00:00
										 |  |  |         with util.uncache(self.name): | 
					
						
							| 
									
										
										
										
											2009-01-27 01:41:57 +00:00
										 |  |  |             loader = machinery.BuiltinImporter.find_module(self.name, ['pkg']) | 
					
						
							|  |  |  |             self.assert_(loader is None) | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def test_main(): | 
					
						
							|  |  |  |     from test.support import run_unittest | 
					
						
							|  |  |  |     run_unittest(FinderTests) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     test_main() |