mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Move built-in loader tests to importlib.test.abc.LoaderTests.
This commit is contained in:
		
							parent
							
								
									fa6cf39e70
								
							
						
					
					
						commit
						d98a6a014d
					
				
					 2 changed files with 24 additions and 5 deletions
				
			
		| 
						 | 
					@ -1,9 +1,8 @@
 | 
				
			||||||
to do
 | 
					to do
 | 
				
			||||||
/////
 | 
					/////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Use test.loader_tests
 | 
					* Use test.abc.LoaderTests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    + builtin
 | 
					 | 
				
			||||||
    + frozen
 | 
					    + frozen
 | 
				
			||||||
    + extension
 | 
					    + extension
 | 
				
			||||||
    + source
 | 
					    + source
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import importlib
 | 
					import importlib
 | 
				
			||||||
from importlib import machinery
 | 
					from importlib import machinery
 | 
				
			||||||
 | 
					from .. import abc
 | 
				
			||||||
from .. import support
 | 
					from .. import support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
| 
						 | 
					@ -7,7 +8,7 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LoaderTests(unittest.TestCase):
 | 
					class LoaderTests(abc.LoaderTests):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """Test load_module() for built-in modules."""
 | 
					    """Test load_module() for built-in modules."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,13 +27,32 @@ def verify(self, module):
 | 
				
			||||||
    load_module = staticmethod(lambda name:
 | 
					    load_module = staticmethod(lambda name:
 | 
				
			||||||
                                machinery.BuiltinImporter.load_module(name))
 | 
					                                machinery.BuiltinImporter.load_module(name))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_load_module(self):
 | 
					    def test_module(self):
 | 
				
			||||||
        # Common case.
 | 
					        # Common case.
 | 
				
			||||||
        with support.uncache(self.name):
 | 
					        with support.uncache(self.name):
 | 
				
			||||||
            module = self.load_module(self.name)
 | 
					            module = self.load_module(self.name)
 | 
				
			||||||
            self.verify(module)
 | 
					            self.verify(module)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_nonexistent(self):
 | 
					    def test_package(self):
 | 
				
			||||||
 | 
					        # Built-in modules cannot be a package.
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_lacking_parent(self):
 | 
				
			||||||
 | 
					        # Built-in modules cannot be a package.
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_state_after_failure(self):
 | 
				
			||||||
 | 
					        # Not way to force an imoprt failure.
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_module_reuse(self):
 | 
				
			||||||
 | 
					        # Test that the same module is used in a reload.
 | 
				
			||||||
 | 
					        with support.uncache(self.name):
 | 
				
			||||||
 | 
					            module1 = self.load_module(self.name)
 | 
				
			||||||
 | 
					            module2 = self.load_module(self.name)
 | 
				
			||||||
 | 
					            self.assert_(module1 is module2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_unloadable(self):
 | 
				
			||||||
        name = 'dssdsdfff'
 | 
					        name = 'dssdsdfff'
 | 
				
			||||||
        assert name not in sys.builtin_module_names
 | 
					        assert name not in sys.builtin_module_names
 | 
				
			||||||
        self.assertRaises(ImportError, self.load_module, name)
 | 
					        self.assertRaises(ImportError, self.load_module, name)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue