bpo-40275: Fix failed test cases by using test helpers (GH-21811)
This commit is contained in:
parent
a02efe4d27
commit
490c5426b1
|
@ -8,7 +8,6 @@ import stat
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import test.support
|
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
|
|
||||||
import _osx_support
|
import _osx_support
|
||||||
|
@ -20,7 +19,7 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.prog_name = 'bogus_program_xxxx'
|
self.prog_name = 'bogus_program_xxxx'
|
||||||
self.temp_path_dir = os.path.abspath(os.getcwd())
|
self.temp_path_dir = os.path.abspath(os.getcwd())
|
||||||
self.env = test.support.EnvironmentVarGuard()
|
self.env = os_helper.EnvironmentVarGuard()
|
||||||
self.addCleanup(self.env.__exit__)
|
self.addCleanup(self.env.__exit__)
|
||||||
for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
for cv in ('CFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||||
'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC',
|
'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'CC',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from importlib import _bootstrap_external
|
from importlib import _bootstrap_external
|
||||||
from test import support
|
from test.support import os_helper
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
from .. import util
|
from .. import util
|
||||||
|
@ -23,7 +23,7 @@ class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
|
||||||
|
|
||||||
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
||||||
def test_case_sensitive(self):
|
def test_case_sensitive(self):
|
||||||
with support.EnvironmentVarGuard() as env:
|
with os_helper.EnvironmentVarGuard() as env:
|
||||||
env.unset('PYTHONCASEOK')
|
env.unset('PYTHONCASEOK')
|
||||||
self.caseok_env_changed(should_exist=False)
|
self.caseok_env_changed(should_exist=False)
|
||||||
loader = self.find_module()
|
loader = self.find_module()
|
||||||
|
@ -31,7 +31,7 @@ class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
|
||||||
|
|
||||||
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
||||||
def test_case_insensitivity(self):
|
def test_case_insensitivity(self):
|
||||||
with support.EnvironmentVarGuard() as env:
|
with os_helper.EnvironmentVarGuard() as env:
|
||||||
env.set('PYTHONCASEOK', '1')
|
env.set('PYTHONCASEOK', '1')
|
||||||
self.caseok_env_changed(should_exist=True)
|
self.caseok_env_changed(should_exist=True)
|
||||||
loader = self.find_module()
|
loader = self.find_module()
|
||||||
|
|
|
@ -7,7 +7,7 @@ importlib = util.import_importlib('importlib')
|
||||||
machinery = util.import_importlib('importlib.machinery')
|
machinery = util.import_importlib('importlib.machinery')
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from test import support as test_support
|
from test.support import os_helper
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class CaseSensitivityTest(util.CASEOKTestBase):
|
||||||
|
|
||||||
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
||||||
def test_sensitive(self):
|
def test_sensitive(self):
|
||||||
with test_support.EnvironmentVarGuard() as env:
|
with os_helper.EnvironmentVarGuard() as env:
|
||||||
env.unset('PYTHONCASEOK')
|
env.unset('PYTHONCASEOK')
|
||||||
self.caseok_env_changed(should_exist=False)
|
self.caseok_env_changed(should_exist=False)
|
||||||
sensitive, insensitive = self.sensitivity_test()
|
sensitive, insensitive = self.sensitivity_test()
|
||||||
|
@ -52,7 +52,7 @@ class CaseSensitivityTest(util.CASEOKTestBase):
|
||||||
|
|
||||||
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
|
||||||
def test_insensitive(self):
|
def test_insensitive(self):
|
||||||
with test_support.EnvironmentVarGuard() as env:
|
with os_helper.EnvironmentVarGuard() as env:
|
||||||
env.set('PYTHONCASEOK', '1')
|
env.set('PYTHONCASEOK', '1')
|
||||||
self.caseok_env_changed(should_exist=True)
|
self.caseok_env_changed(should_exist=True)
|
||||||
sensitive, insensitive = self.sensitivity_test()
|
sensitive, insensitive = self.sensitivity_test()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import signal
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from test import support
|
from test import support
|
||||||
|
from test.support import os_helper
|
||||||
from test.support import socket_helper
|
from test.support import socket_helper
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -536,7 +537,7 @@ class KqueueSelectorTestCase(BaseSelectorTestCase, ScalableSelectorMixIn):
|
||||||
# a file descriptor that's been closed should raise an OSError
|
# a file descriptor that's been closed should raise an OSError
|
||||||
# with EBADF
|
# with EBADF
|
||||||
s = self.SELECTOR()
|
s = self.SELECTOR()
|
||||||
bad_f = support.make_bad_fd()
|
bad_f = os_helper.make_bad_fd()
|
||||||
with self.assertRaises(OSError) as cm:
|
with self.assertRaises(OSError) as cm:
|
||||||
s.register(bad_f, selectors.EVENT_READ)
|
s.register(bad_f, selectors.EVENT_READ)
|
||||||
self.assertEqual(cm.exception.errno, errno.EBADF)
|
self.assertEqual(cm.exception.errno, errno.EBADF)
|
||||||
|
|
Loading…
Reference in New Issue