mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
test: update importlib
This commit is contained in:
1 file changed
+10
-3
+10
-3
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user