test: update importlib

This commit is contained in:
Dean Li committed 2021-11-28 20:51:34 +08:00
1 parent 05705bd727
commit cad10fedd4
1 file changed
+10 -3
+10 -3
View File
@@ -1,12 +1,15 @@
"""Test case-sensitivity (PEP 235)."""
import sys
from .. import util
importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')
import os
from test import support as test_support
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
@@ -38,8 +41,9 @@ class CaseSensitivityTest(util.CASEOKTestBase):
insensitive_finder = self.finder(insensitive_path)
return self.find(sensitive_finder), self.find(insensitive_finder)
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_sensitive(self):
with test_support.EnvironmentVarGuard() as env:
with os_helper.EnvironmentVarGuard() as env:
env.unset('PYTHONCASEOK')
self.caseok_env_changed(should_exist=False)
sensitive, insensitive = self.sensitivity_test()
@@ -47,8 +51,9 @@ class CaseSensitivityTest(util.CASEOKTestBase):
self.assertIn(self.name, sensitive.get_filename(self.name))
self.assertIsNone(insensitive)
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_insensitive(self):
with test_support.EnvironmentVarGuard() as env:
with os_helper.EnvironmentVarGuard() as env:
env.set('PYTHONCASEOK', '1')
self.caseok_env_changed(should_exist=True)
sensitive, insensitive = self.sensitivity_test()
@@ -60,6 +65,8 @@ class CaseSensitivityTest(util.CASEOKTestBase):
class CaseSensitivityTestPEP302(CaseSensitivityTest):
def find(self, finder):
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return finder.find_module(self.name)