bpo-40275: Use new test.support helper submodules in tests (GH-21785)
This commit is contained in:
parent
d94af3f7ed
commit
c6f282f3b1
|
@ -77,7 +77,7 @@ class saved_test_environment:
|
||||||
return list(urllib.request._url_tempfiles)
|
return list(urllib.request._url_tempfiles)
|
||||||
def restore_urllib_requests__url_tempfiles(self, tempfiles):
|
def restore_urllib_requests__url_tempfiles(self, tempfiles):
|
||||||
for filename in tempfiles:
|
for filename in tempfiles:
|
||||||
support.unlink(filename)
|
os_helper.unlink(filename)
|
||||||
|
|
||||||
def get_urllib_requests__opener(self):
|
def get_urllib_requests__opener(self):
|
||||||
return urllib.request._opener
|
return urllib.request._opener
|
||||||
|
@ -245,9 +245,9 @@ class saved_test_environment:
|
||||||
fn = os_helper.TESTFN
|
fn = os_helper.TESTFN
|
||||||
if fn not in saved_value and (fn + '/') not in saved_value:
|
if fn not in saved_value and (fn + '/') not in saved_value:
|
||||||
if os.path.isfile(fn):
|
if os.path.isfile(fn):
|
||||||
support.unlink(fn)
|
os_helper.unlink(fn)
|
||||||
elif os.path.isdir(fn):
|
elif os.path.isdir(fn):
|
||||||
support.rmtree(fn)
|
os_helper.rmtree(fn)
|
||||||
|
|
||||||
_lc = [getattr(locale, lc) for lc in dir(locale)
|
_lc = [getattr(locale, lc) for lc in dir(locale)
|
||||||
if lc.startswith('LC_')]
|
if lc.startswith('LC_')]
|
||||||
|
|
|
@ -9,6 +9,7 @@ import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import test.support
|
import test.support
|
||||||
|
from test.support import os_helper
|
||||||
|
|
||||||
import _osx_support
|
import _osx_support
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
if self.env['PATH']:
|
if self.env['PATH']:
|
||||||
self.env['PATH'] = self.env['PATH'] + ':'
|
self.env['PATH'] = self.env['PATH'] + ':'
|
||||||
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
||||||
test.support.unlink(self.prog_name)
|
os_helper.unlink(self.prog_name)
|
||||||
self.assertIsNone(_osx_support._find_executable(self.prog_name))
|
self.assertIsNone(_osx_support._find_executable(self.prog_name))
|
||||||
self.addCleanup(test.support.unlink, self.prog_name)
|
self.addCleanup(os_helper.unlink, self.prog_name)
|
||||||
with open(self.prog_name, 'w') as f:
|
with open(self.prog_name, 'w') as f:
|
||||||
f.write("#!/bin/sh\n/bin/echo OK\n")
|
f.write("#!/bin/sh\n/bin/echo OK\n")
|
||||||
os.chmod(self.prog_name, stat.S_IRWXU)
|
os.chmod(self.prog_name, stat.S_IRWXU)
|
||||||
|
@ -52,8 +53,8 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
if self.env['PATH']:
|
if self.env['PATH']:
|
||||||
self.env['PATH'] = self.env['PATH'] + ':'
|
self.env['PATH'] = self.env['PATH'] + ':'
|
||||||
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
|
||||||
test.support.unlink(self.prog_name)
|
os_helper.unlink(self.prog_name)
|
||||||
self.addCleanup(test.support.unlink, self.prog_name)
|
self.addCleanup(os_helper.unlink, self.prog_name)
|
||||||
with open(self.prog_name, 'w') as f:
|
with open(self.prog_name, 'w') as f:
|
||||||
f.write("#!/bin/sh\n/bin/echo ExpectedOutput\n")
|
f.write("#!/bin/sh\n/bin/echo ExpectedOutput\n")
|
||||||
os.chmod(self.prog_name, stat.S_IRWXU)
|
os.chmod(self.prog_name, stat.S_IRWXU)
|
||||||
|
@ -143,8 +144,8 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
|
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
|
||||||
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
||||||
for c_name, c_output in compilers:
|
for c_name, c_output in compilers:
|
||||||
test.support.unlink(c_name)
|
os_helper.unlink(c_name)
|
||||||
self.addCleanup(test.support.unlink, c_name)
|
self.addCleanup(os_helper.unlink, c_name)
|
||||||
with open(c_name, 'w') as f:
|
with open(c_name, 'w') as f:
|
||||||
f.write("#!/bin/sh\n/bin/echo " + c_output)
|
f.write("#!/bin/sh\n/bin/echo " + c_output)
|
||||||
os.chmod(c_name, stat.S_IRWXU)
|
os.chmod(c_name, stat.S_IRWXU)
|
||||||
|
@ -221,8 +222,8 @@ class Test_OSXSupport(unittest.TestCase):
|
||||||
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
|
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
|
||||||
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
|
||||||
c_name = 'clang'
|
c_name = 'clang'
|
||||||
test.support.unlink(c_name)
|
os_helper.unlink(c_name)
|
||||||
self.addCleanup(test.support.unlink, c_name)
|
self.addCleanup(os_helper.unlink, c_name)
|
||||||
# exit status 255 means no PPC support in this compiler chain
|
# exit status 255 means no PPC support in this compiler chain
|
||||||
with open(c_name, 'w') as f:
|
with open(c_name, 'w') as f:
|
||||||
f.write("#!/bin/sh\nexit 255")
|
f.write("#!/bin/sh\nexit 255")
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from test import support
|
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
import_helper.import_module("dbm.ndbm") #skip if not supported
|
import_helper.import_module("dbm.ndbm") #skip if not supported
|
||||||
|
@ -16,7 +15,7 @@ class DbmTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for suffix in ['', '.pag', '.dir', '.db']:
|
for suffix in ['', '.pag', '.dir', '.db']:
|
||||||
support.unlink(self.filename + suffix)
|
os_helper.unlink(self.filename + suffix)
|
||||||
|
|
||||||
def test_keys(self):
|
def test_keys(self):
|
||||||
self.d = dbm.ndbm.open(self.filename, 'c')
|
self.d = dbm.ndbm.open(self.filename, 'c')
|
||||||
|
@ -108,7 +107,7 @@ class DbmTestCase(unittest.TestCase):
|
||||||
def test_nonascii_filename(self):
|
def test_nonascii_filename(self):
|
||||||
filename = os_helper.TESTFN_NONASCII
|
filename = os_helper.TESTFN_NONASCII
|
||||||
for suffix in ['', '.pag', '.dir', '.db']:
|
for suffix in ['', '.pag', '.dir', '.db']:
|
||||||
self.addCleanup(support.unlink, filename + suffix)
|
self.addCleanup(os_helper.unlink, filename + suffix)
|
||||||
with dbm.ndbm.open(filename, 'c') as db:
|
with dbm.ndbm.open(filename, 'c') as db:
|
||||||
db[b'key'] = b'value'
|
db[b'key'] = b'value'
|
||||||
self.assertTrue(any(os.path.exists(filename + suffix)
|
self.assertTrue(any(os.path.exists(filename + suffix)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import sys
|
||||||
|
|
||||||
from tempfile import TemporaryFile
|
from tempfile import TemporaryFile
|
||||||
|
|
||||||
|
from test.support import os_helper
|
||||||
from test.support import TESTFN, requires_zlib
|
from test.support import TESTFN, requires_zlib
|
||||||
|
|
||||||
TESTFN2 = TESTFN + "2"
|
TESTFN2 = TESTFN + "2"
|
||||||
|
@ -138,8 +139,8 @@ class OtherTests(unittest.TestCase):
|
||||||
self.assertEqual(content, "%d" % (i**3 % 57))
|
self.assertEqual(content, "%d" % (i**3 % 57))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
support.unlink(TESTFN)
|
os_helper.unlink(TESTFN)
|
||||||
support.unlink(TESTFN2)
|
os_helper.unlink(TESTFN2)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue