| 
									
										
										
										
											2022-01-22 19:05:05 +03:00
										 |  |  | from test.test_importlib import util | 
					
						
							| 
									
										
										
										
											2012-04-14 14:10:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-08 14:25:37 -05:00
										 |  |  | machinery = util.import_importlib('importlib.machinery') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | import unittest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-08 14:25:37 -05:00
										 |  |  | class PathHookTest: | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     """Test the path hook for source.""" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-22 19:58:33 -04:00
										 |  |  |     def path_hook(self): | 
					
						
							| 
									
										
										
										
											2013-11-08 14:25:37 -05:00
										 |  |  |         return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader, | 
					
						
							|  |  |  |             self.machinery.SOURCE_SUFFIXES)) | 
					
						
							| 
									
										
										
										
											2012-04-22 19:58:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  |     def test_success(self): | 
					
						
							| 
									
										
										
										
											2014-05-09 14:32:57 -04:00
										 |  |  |         with util.create_modules('dummy') as mapping: | 
					
						
							| 
									
										
										
										
											2012-04-22 19:58:33 -04:00
										 |  |  |             self.assertTrue(hasattr(self.path_hook()(mapping['.root']), | 
					
						
							| 
									
										
										
										
											2016-05-10 16:21:03 -06:00
										 |  |  |                                     'find_spec')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-03 22:18:47 +00:00
										 |  |  |     def test_empty_string(self): | 
					
						
							| 
									
										
										
										
											2016-05-10 16:21:03 -06:00
										 |  |  |         # The empty string represents the cwd. | 
					
						
							|  |  |  |         self.assertTrue(hasattr(self.path_hook()(''), 'find_spec')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 11:40:40 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | (Frozen_PathHookTest, | 
					
						
							|  |  |  |  Source_PathHooktest | 
					
						
							|  |  |  |  ) = util.test_both(PathHookTest, machinery=machinery) | 
					
						
							| 
									
										
										
										
											2009-01-18 00:24:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2013-11-08 14:25:37 -05:00
										 |  |  |     unittest.main() |