mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	case-sensitive filesystems -- which is not the default case. Along the way also fixed the skipping of tests when sys.dont_write_bytecode is true. Closes issue #5442 again.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import sys
 | 
						|
from test import support
 | 
						|
import unittest
 | 
						|
from importlib import _bootstrap
 | 
						|
from .. import util
 | 
						|
from . import util as ext_util
 | 
						|
 | 
						|
 | 
						|
@util.case_insensitive_tests
 | 
						|
class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
 | 
						|
 | 
						|
    def find_module(self):
 | 
						|
        good_name = ext_util.NAME
 | 
						|
        bad_name = good_name.upper()
 | 
						|
        assert good_name != bad_name
 | 
						|
        finder = _bootstrap._ExtensionFileFinder(ext_util.PATH)
 | 
						|
        return finder.find_module(bad_name)
 | 
						|
 | 
						|
    def test_case_sensitive(self):
 | 
						|
        with support.EnvironmentVarGuard() as env:
 | 
						|
            env.unset('PYTHONCASEOK')
 | 
						|
            loader = self.find_module()
 | 
						|
            self.assertIsNone(loader)
 | 
						|
 | 
						|
    def test_case_insensitivity(self):
 | 
						|
        with support.EnvironmentVarGuard() as env:
 | 
						|
            env.set('PYTHONCASEOK', '1')
 | 
						|
            loader = self.find_module()
 | 
						|
            self.assertTrue(hasattr(loader, 'load_module'))
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
def test_main():
 | 
						|
    if ext_util.FILENAME is None:
 | 
						|
        return
 | 
						|
    support.run_unittest(ExtensionModuleCaseSensitivityTest)
 | 
						|
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    test_main()
 |